LearnPy Hub
← Arena
AdvancedRating 1500

Balanced Zeros and Ones

Print the length of the longest contiguous subarray with equally many 0s and 1s.

Input

n, then n values (0 or 1).

Output

A length.

Sample 1

Input
2
0 1
Output
2

Sample 2

Input
3
0 1 0
Output
2
solution.py
Output appears here
Balanced Zeros and Ones · Python Arena problem · LearnPy Hub