#C1604. Counting Equal Subarrays

    ID: 44828 Type: Default 1000ms 256MiB

Counting Equal Subarrays

Counting Equal Subarrays

You are given an array of ( n ) integers. Your task is to count the number of contiguous subarrays in which all elements are equal. A contiguous subarray is a sequence of consecutive elements in the array. For example, if a segment of the array consists of ( L ) identical elements, then the number of subarrays that can be formed from this segment is given by ( \frac{L(L+1)}{2} ). Write a program to compute this count.

inputFormat

The first line contains an integer ( n ) which denotes 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 total number of contiguous subarrays in which all elements are equal.## sample

1
1
1

</p>