/**
 *      AGC 23 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-11 01:40:56
**/

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    int A[N] = {};
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    int s[N] = {};      // 累積和
    s[0] = A[0];
    for (int i = 1; i < N; ++i) {
        s[i] = A[i] + s[i - 1];
    }

    sort(s, s + N);
    
    ll answer = 0;     // 配列の連続する同じ要素に対する操作：tourist のコードから拝借
    int begin = 0;
    
    for (int i = 0; i < N; ++i) {
        if (s[i] == 0){
            ++answer;
        }
    }
    
    while (begin < N){
        int end = begin;
        while (end + 1 < N && s[end + 1] == s[begin]){
            ++end;
        }
        ll len = end - begin + 1;
        answer += len * (len - 1) / 2;
        begin = end + 1;        
    }
    cout << answer << endl;

    return 0;
}