#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
long long a[maxn];
map<long long, int> col;
int main() {
  int n;
  scanf("%d", &n);
  a[0] = 0LL;
  col[0]++;
  long long temp;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &temp);
    a[i] = a[i - 1] + temp;
    col[a[i]]++;
  }
  map<long long, int>::iterator it;
  long long sum = 0LL;
  for (it = col.begin(); it != col.end(); it++) {
    long long now = it->second;
    sum += now * (now - 1LL) / 2LL;
  }
  printf("%lld\n", sum);
  return 0;
}
