#include <bits/stdc++.h>
using namespace std;
long f(int n) {
  long abc = 1;
  for (int i = n; i > n - 2; --i) {
    abc = abc * i;
  }
  abc = abc / 2;
  return abc;
}
int main() {
  int n;
  cin >> n;
  int A[200000];
  for (int i = 0; i < n; i++) cin >> A[i];
  long ans = 0;
  int sum[20000];
  sum[0] = A[0];
  for (int i = 1; i < n; i++) {
    sum[i] = (sum[i - 1] + A[i]) % 2147483647;
  }
  for (int i = 0; i < n; i++) {
    if (sum[i] == 0) ans++;
  }
  sort(sum, sum + n);
  int ptr = 0;
  long cc;
  while (ptr < n) {
    cc = sum[ptr];
    int e = 0;
    while (ptr < n && sum[ptr] == cc) e++, ptr++;
    ans += f(e);
  }
  cout << ans;
}
