#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N;
  cin >> N;
  vector<long long> A(N);
  for (long long i = (long long)(0); i < (long long)(N); i++) cin >> A[i];
  vector<long long> B(N + 1);
  long long ans = 0;
  map<long long, long long> M;
  M[0]++;
  for (long long i = (long long)(0); i < (long long)(N); i++) {
    B[i + 1] = B[i] + A[i];
    ans += M[-B[i + 1]];
    M[B[i + 1]]++;
  }
  cout << ans << endl;
}
