Question
Count Subarrays with All Ones
You are given an array of KaTeX can only parse string typed expression integers. Each element of the array is either KaTeX can only parse string typed expression or KaTeX can only parse string typed expression. Your task is to count the number of subarrays that contain only KaTeX can only parse string typed expressions.
Input
The first line contains a single integer KaTeX can only parse string typed expression — the size of the array.
The second line contains KaTeX can only parse string typed expression integers, representing the elements of the array — KaTeX can only parse string typed expression, where each element is either KaTeX can only parse string typed expression or KaTeX can only parse string typed expression.
Output
Print a single integer — the number of subarrays consisting only of KaTeX can only parse string typed expressions.
Example
Input
5
1 1 0 1 1

Output
6

Explanation
Valid subarrays with all KaTeX can only parse string typed expressions based on the indices:
[0]
[0, 1]
[1]
[3]
[3, 4]
[4]
Total = 6 subarrays.

Online