// https://atcoder.jp/contests/agc023/tasks/agc023_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int his[1000000000];
int main() {
    int n;
    cin >> n;
    vector<ll> dp(n + 1, 0);
    REP(i, n) {
        ll t;
        cin >> t;
        dp[i + 1] = dp[i] + t;
    }
    ll cnt = 0;
    REPR(i, n + 1) {
        cnt += his[dp[i]];
        his[dp[i]]++;
    }
    cout << cnt << endl;

    return 0;
}
