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