#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int N;
    cin >> N ;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    
    // 累積和
    vector<ll> s(N+1, 0);
    map<ll, ll> nums;
    REP(i, N) s[i+1] = s[i] + a[i];
    REP(i, N+1) nums[s[i]]++;

    // 集計
    ll ans = 0;
    for(auto it : nums) {
        ll num = it.second;
        ans += num * (num-1) / 2;
    }

    cout << ans << endl;

    return 0;
}