#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N, 0);
    REP(i, 0, N) {
        cin >> A[i];
    }
    int ans = 0;
    vector<int> B(N + 1, 0);
    map<int, int> m;
    m[0]++;
    REP(i, 0, N) {
        B[i + 1] += B[i] + A[i];
        ans += m[B[i + 1]];
        //        dump(ans);
        m[B[i + 1]]++;
    }
    cout << ans << endl;

    return 0;
}