#C12440. Longest Contiguous Even Sublist

    ID: 41868 Type: Default 1000ms 256MiB

Longest Contiguous Even Sublist

Longest Contiguous Even Sublist

Given an array of integers, your task is to determine the length of the longest contiguous subarray that contains only even numbers. If the array does not contain any even numbers, the answer is 0.

Formally, let \(a_1, a_2, \dots, a_n\) be the array of integers. Find the maximum integer \(L\) such that there exists an index \(i\) with \(1 \le i \le n-L+1\) and for all \(j = i, i+1, \dots, i+L-1\), \(a_j \bmod 2 = 0\). If no such \(L\) exists, output 0.

inputFormat

The input is read from standard input and consists of two lines:

  • The first line contains a single integer \(n\) representing the number of elements in the list.
  • The second line contains \(n\) space-separated integers.

If \(n = 0\), the second line may be omitted.

outputFormat

Output a single integer representing the length of the longest contiguous sublist that contains only even numbers.

## sample
8
5 10 20 6 3 12 14 7
3