#include <bits/stdc++.h>
using namespace std;
long long vs[100000 + 10];
long long cs[100000 + 10];
int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < (int)(n); ++i) {
    scanf("%lld", &vs[i]);
  }
  for (int i = 0; i < (int)(n); ++i) {
    cs[i + 1] = cs[i] + vs[i];
  }
  map<long long, long long> mm;
  for (int i = 0; i < (int)(n + 1); ++i) {
    mm[cs[i]]++;
  }
  long long res = 0;
  for (__typeof((mm).begin()) it = (mm).begin(); it != (mm).end(); ++it) {
    long long k = it->second;
    res += k * (k - 1) / 2;
  }
  cout << res << endl;
  return 0;
}
