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