#include <bits/stdc++.h>
using namespace std;
vector<int> v;
long long n, a[200005], sum[200005], cnt = 1, k = 0;
int main() {
  scanf("%lld", &n);
  memset(a, 0, sizeof a);
  memset(sum, 0, sizeof sum);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1] + a[i];
    v.push_back(sum[i]);
    if (sum[i] == 0) {
      ++k;
    }
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); i++) {
    if (i == 0) {
      continue;
    }
    if (v[i] == v[i - 1]) {
      ++cnt;
    } else {
      k += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  k += cnt * (cnt - 1) / 2;
  cout << k;
}
