#P9956. Bessie's Average Flower Photo

    ID: 23100 Type: Default 1000ms 256MiB

Bessie's Average Flower Photo

Bessie's Average Flower Photo

Bessie the cow loves taking photos of her favorite flower field. The field has N daisies arranged in a row, where each flower i has pi petals. For every contiguous segment of flowers (i.e. for every pair of indices \(1 \le i \le j \le N\)), Bessie takes a photo of all the flowers from the i-th to the j-th flower (inclusive).

After taking all the photos, Bessie notices that some photos have an "average" flower. A photo is said to contain an average flower if there exists a flower in the photo with exactly \(P\) petals, where \(P\) is the average number of petals in that photo. Note that the average is defined as:

[ P = \frac{\sum_{k=i}^{j} p_k}{j-i+1} ]

Count the number of photos that contain an average flower.

inputFormat

The first line contains an integer \(N\) (\(1 \le N \le 100\)), representing the number of flowers. The second line contains \(N\) integers \(p_1, p_2, \dots, p_N\) (\(1 \le p_i \le 1000\)), where \(p_i\) is the number of petals of the i-th flower.

outputFormat

Output a single integer: the number of photos that contain an average flower.

sample

4
1 1 2 3
6

</p>