#include "iostream"
#include "vector"
#include "algorithm"
#include "map"
#define N_MAX  200005

using namespace std;

typedef long long llint;

int N;
int A[N_MAX];
int A_sum[N_MAX];
int dp[N_MAX][N_MAX];

int main() {

    cin >> N;

    map<int, vector<int > > x;

    // int cnt = 0;
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
    }

    A_sum[0] = 0;
    for (int i = 1; i <= N; i++) {
        A_sum[i] = A_sum[i - 1] + A[i];
    }
    
    for (int i = 0; i <= N; i++) {
        vector<int> sums = x[A_sum[i]];
        sums.push_back(i);
        x[A_sum[i]] = sums;
    }

    int ans = 0;
    for (auto elem : x) {
        // vector<int > n = elem.second;
        // cout << elem.first << " " << (elem.second).size() << endl;
        int n = (elem.second).size() - 1;
        // if (sums.size() > 1) {
        ans += n * (n + 1) / 2;
        // }
    }

    cout << ans << endl;
}