#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main() {

        int N; cin >> N;

        vector<int int> a(N, 0);

        for (int i = 0; i < N; ++i) cin >> a[i];

        vector<int int> s(N+1, 0);

        for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

        std::sort(s.begin(), s.end());

        int count = 0;

        int res = 0;


        for (int i = 0; i < N+1; ++i){
                if (i == 0) continue;

                if (s[i] == s[i-1]) {
                        count += 1;
                        res += count;
                }
                else count = 0;
        }

        cout << res << endl;
}
