#K95932. Count Beautiful Subarrays

    ID: 38973 Type: Default 1000ms 256MiB

Count Beautiful Subarrays

Count Beautiful Subarrays

Problem Statement:

Given an array (a) of (n) integers, a subarray is called beautiful if all the elements in the subarray are even. In other words, for any subarray defined by indices (i) and (j) (with (1 \le i \le j \le n)), it is considered beautiful if every element (a_k) for (i \le k \le j) is even.

The number of beautiful subarrays in a contiguous block of even numbers of length (L) can be computed by using the formula:
[ \frac{L\times (L+1)}{2} ]

Your task is to compute the total number of beautiful (i.e., all even) subarrays in the given array.

inputFormat

Input is read from standard input (stdin).

The first line contains a single integer (n) ((1 \le n \le 2\times10^5)) — the number of integers in the array. The second line contains (n) space-separated integers representing the array (a).

outputFormat

Output a single integer to standard output (stdout) — the total number of beautiful subarrays.## sample

1
2
1

</p>