#K906. Sum of Unique Prefix Frequencies
Sum of Unique Prefix Frequencies
Sum of Unique Prefix Frequencies
You are given a sequence of n integers. Your task is to compute the sum of frequencies of all unique prefix sums computed from the sequence.
More formally, let sequence be an array of integers and define the prefix sum Si as:
$$S_i = \sum_{j=1}^{i} a_j \quad \text{for } 1 \le i \le n. $$You need to calculate the frequency (i.e. the number of occurrences) of each unique prefix sum and return the sum of these frequencies.
Note: The input is provided via standard input and the output should be printed to standard output.
inputFormat
The first line contains an integer n representing the number of elements in the sequence.
The second line contains n space-separated integers representing the sequence.
outputFormat
Output a single integer which is the sum of frequencies of all unique prefix sums computed from the sequence.
## sample5
1 2 3 2 -4
5