#include <bits/stdc++.h>
using namespace std;
long long n;
long long a[210000], pre[210000];
int main() {
  cin >> n;
  long long ans = 0;
  pre[0] = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    pre[i] = pre[i - 1] + a[i];
  }
  sort(pre, pre + n + 1);
  for (int i = 0; i <= n; i++) {
    long long cnt = 1;
    while (pre[i + 1] == pre[i] && i <= n) {
      cnt++;
      i++;
    }
    ans += (cnt * (cnt - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}
