#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long n, cnt = 0, memo = 0;
  cin >> n;
  unsigned long long a[n], sum[n];
  for (int i = (0); i < (n); i++) {
    cin >> a[i];
    sum[i] = (i == 0) ? a[i] : sum[i - 1] + a[i];
  }
  sort(sum, sum + n);
  for (int i = (1); i < (n); i++) {
    if (sum[i] != sum[i - 1]) {
      if (sum[i - 1] == 0) {
        cnt += memo + 1;
      }
      memo = 0;
    } else {
      memo++;
      cnt += memo;
    }
  }
  cout << cnt << endl;
  return 0;
}
