SOLVE
LATER
Given an Array A consisting of 0's and 1's of length N. The goodness of a subarray is defined as difference between number of 1's and number of 0's present in the subarray.Output the length of longest subarray with maximum value of goodness.
Input:
The first line of Input contains Integer N.
The second line contains N space-separated integers A1, A2, ..., AN denoting the elements of array A.
Output:
Print length of Longest subarray with maximum goodness value.
Constraints:
1 ≤ N ≤ \(10^{3}\)
0 ≤ A[i] ≤ 1
The maximum value of difference of count of 1's and count of 0's is 4 corresponding to subarrays [1,8] and [1,4] assuming 1 based indexing of array but longest subarray is [1,8] hence answer is 8.