#K391. Longest Even Subarray

    ID: 26345 Type: Default 1000ms 256MiB

Longest Even Subarray

Longest Even Subarray

Given an array of integers, your task is to find the length of the longest contiguous subarray that consists only of even numbers. If there is no even number in the array, the result should be 0.

Formally, let (a_1, a_2, \dots, a_n) be the input array. You need to determine the maximum integer (L) such that there exists an index (i) with (1 \leq i \leq n-L+1) and for all (j = i, i+1, \dots, i+L-1), (a_j) is even. If no such (L > 0) exists, output 0.

inputFormat

The first line contains a single integer (n) ((0 \leq n \leq 10^4)) — the number of elements in the array. The second line contains (n) space-separated integers representing the elements of the array.

outputFormat

Output a single integer — the length of the longest contiguous subarray consisting solely of even numbers. If no even number exists, output 0.## sample

8
1 2 4 6 3 8 10 7
3