#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <iomanip>
 
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

int N, K;

int main() {
    cin >> N;
    long long a[N+1] = {};
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
        a[i] += a[i-1];
    }
    sort(a, a + N + 1);
    int n = 0;
    int k = 1;
    long long ans = 0;
    for (int i = 1; i < N+1; i++) {
        if (a[i] == n) {
            k++;
        } else {
            ans += (k * (k-1)) / 2;
            k = 1;
            n = a[i];
        }
    }
    ans += (k * (k-1)) / 2;
    cout << ans << endl;
 
    return 0;
}