#include <bits/stdc++.h>
using namespace std;
int n;
long long sum[200001] = {};
map<long long, int> mp;
int main() {
  mp[0] = 1;
  long long a;
  int ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    cin >> a;
    sum[i] = sum[i - 1] + a;
    if (mp.count(sum[i]) == 0) {
      mp[sum[i]] = 1;
    } else {
      ans += mp[sum[i]];
      mp[sum[i]]++;
    }
  }
  printf("%d\n", ans);
  return (0);
}
