#include <bits/stdc++.h>
using namespace std;
static long long P = 1000000007LL;
int main(int argc, char* argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> A, S;
  map<long long, int> M;
  A.push_back(0);
  S.push_back(0);
  for (int i = 1; i <= N; i++) {
    long long a;
    cin >> a;
    A.push_back(a);
    long long s = S[i - 1] + a;
    S.push_back(s);
    if (M.count(s) == 0) {
      M[s] = 1;
    } else {
      M[s]++;
    }
  }
  long long ans = 0;
  for (auto itr = M.begin(); itr != M.end(); itr++) {
    long long k = itr->first;
    int v = itr->second;
    if (v > 1) {
      int w = v * (v - 1);
      w = w / 2;
      ans += w;
    }
    if (k == 0) {
      ans += v;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
