#include <iostream>
#include <map>
using namespace std;

int main() {
    int n;
    long long result = 0;
    cin >> n;
    map<long long, long long> count;
    count[0] = 1;
    for (long long a, sum = 0; cin >> a; ) {
        sum += a;
        result += count[sum]++;
    }
    cout << result;
    return 0;
}