#include <bits/stdc++.h>
using namespace std;
template <class T>
using vv = vector<vector<T> >;
int main() {
  int n;
  scanf("%d", &n);
  vector<long long> a(n);
  for (int(i) = (0); (i) < (n); ++(i)) {
    scanf("%lld", &a[i]);
  }
  map<long long, long long> cnt;
  long long sum = 0;
  cnt[sum] += 1;
  for (int(i) = (0); (i) < (n); ++(i)) {
    sum += a[i];
    cnt[sum] += 1;
  }
  long long ans = 0;
  for (auto cn : cnt) {
    int cs = cn.second;
    ans += cs * (cs - 1) / 2;
  }
  printf("%lld\n", ans);
  return 0;
}
