#include <bits/stdc++.h>
using namespace std;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
long long GCD(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return GCD(b, a % b);
}
long long modpow(long long n, long long k) {
  if (k == 1) {
    return n;
  } else if (k == 0) {
    return 1;
  } else if (k % 2 == 0) {
    long long memo = modpow(n, k / 2) % 1000000007;
    return memo * memo % 1000000007;
  } else {
    return n * modpow(n, k - 1) % 1000000007;
  }
}
int main() {
  long long n;
  cin >> n;
  long long a[n];
  cin >> a[0];
  for (int i = 1; i < n; i++) {
    long long t;
    cin >> t;
    a[i] = a[i - 1] + t;
  }
  vector<long long> v;
  for (int i = 0; i < n; i++) {
    v.push_back(a[i]);
  }
  sort(v.begin(), v.end());
  ;
  long long ans = 0;
  int i = 1;
  int count = 1;
  while (i < n) {
    if (v[i] != v[i - 1]) {
      ans += count * (count - 1) / 2;
      count = 0;
    }
    count++;
    i++;
  }
  ans += count * (count - 1) / 2;
  cout << ans << endl;
  return 0;
}
