PDP-23 (2011) - Camp junior - 1 (oddeven)

View as PDF

Submit solution

Points: 30 (partial)
Time limit: 1.0s
Memory limit: 16M

Author:
Problem type
Allowed languages
C, C++, Java, Pascal, Python

ODDEVEN

You are given a sequence a_1, ..., a_N consisting of N positive integers. We are asked to calculate the width of the largest interval in the sequence where the number of even integers equals the number of odd integers.

Input

The first line of input will contain the number of elements in the sequence, N. The second line of input will contain N positive integers separated by spaces, representing the sequence.

Output

The output should consist of a single line containing exactly one integer, the width of the largest interval in the sequence where the number of even integers equals the number of odd integers. If no such interval exists, the output should be 0.

Constraints

2 \le N \le 1.000.000.
Execution time limit: 1 sec.
Maximum available memory: 16 MB.

Examples of Input - Output
1st

STDIN (oddeven.in)

5
7 8 9 6 5

STDOUT (oddeven.out)

4
2nd

STDIN (oddeven.in)

10
1 2 1 2 1 2 2 1 1 1

STDOUT (oddeven.out)

8
3d

STDIN (oddeven.in)

10
4 6 8 2 2 6 8 4 2 8

STDOUT (oddeven.out)

0

Comments

There are no comments at the moment.