#ifdef local_mode
    #include <cstdio>
    #include <cassert>
#endif
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
#define pb push_back
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
#ifdef local_mode
    ios_base::sync_with_stdio(0), cin.tie(0);
    assert(freopen("in", "r", stdin));
    assert(freopen("out", "w", stdout));
#endif
    
    int n;
    cin >> n;

    vector<l> a(n);
    vector<ll> b(n + 1);
    b[0] = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[i + 1] = b[i] + a[i];  // sum [0..i]
    }

    int cnt = 0;
    unordered_map<int, int> m;
    for (int i = 0; i < n + 1; i++)
        m[b[i]]++;

    for (pair<int, int> p : m)
        cnt += p.second * (p.second - 1) / 2;

    cout << cnt;

    return 0;
}





































