#include <bits/stdc++.h>
using namespace std;
int nC2(int x) {
  if (x == 1)
    return 0;
  else
    return (x * (x - 1)) / 2;
}
int main() {
  int N;
  cin >> N;
  vector<long long> A(N + 1);
  A[0] = 0;
  for (int i = 1; i <= N; i++) {
    long long k;
    cin >> k;
    A[i] = A[i - 1] + k;
  }
  sort(A.begin(), A.end());
  int count = 1;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (A[i] == A[i - 1]) {
      count++;
    } else {
      ans += nC2(count);
      count = 1;
    }
  }
  ans += nC2(count);
  cout << ans << endl;
}
