#C13541. Longest Even-Odd Subarray

    ID: 43091 Type: Default 1000ms 256MiB

Longest Even-Odd Subarray

Longest Even-Odd Subarray

Given an integer array, find the length of the longest contiguous subarray that contains an equal number of even and odd numbers.

You are required to process input from stdin and output the result to stdout.

Let \(\text{even}\) indicate an even number and \(\text{odd}\) indicate an odd number. We are looking for a subarray such that:

\[ \#even - \#odd = 0 \]

Your task is to find the maximum length of such a subarray. If no such subarray exists, output 0.

inputFormat

The first line contains a single integer \(n\) which is the number of elements in the array.

The second line contains \(n\) space-separated integers representing the array.

outputFormat

Output a single integer, the length of the longest contiguous subarray that contains equal numbers of even and odd integers.

## sample
4
2 4 6 8
0

</p>