#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  long long ans = 0;
  int s = 0;
  map<long long, long long> q;
  q[0] = 1;
  for (int i = 0; i < n; i++) {
    long long x;
    scanf("%llu", &x);
    s += x;
    if (q.count(s)) {
      ans += q[s];
    }
    q[s]++;
  }
  printf("%llu\n", ans);
  return 0;
}
