#include <bits/stdc++.h>
using namespace std;
long long pre[110000];
map<long long, int> ma;
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    int x;
    ma.clear();
    memset(pre, 0, sizeof(pre));
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &x);
      pre[i] = pre[i - 1] + x;
    }
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
      if (pre[i] == 0) ++cnt;
      cnt += ma[pre[i]];
      ma[pre[i]]++;
    }
    printf("%d\n", cnt);
  }
  return 0;
}
