#include <bits/stdc++.h>
using namespace std;
long long ncr(int n, int r) {
  long long g = 1;
  for (int i = 1; i <= r; i++) {
    g *= (n - r + i);
    g /= i;
  }
  return g;
}
int main() {
  int N;
  cin >> N;
  vector<long long> a(N);
  for (int i = 0; i < N; ++i) cin >> a[i];
  vector<long long> s(N + 1, 0);
  map<long, long> t;
  for (int i = 0; i < N; ++i) {
    s[i + 1] = s[i] + a[i];
    t[s[i + 1]]++;
  }
  int gg = 0;
  for (auto i = t.begin(); i != t.end(); ++i) {
    if (i->first == 0) {
      gg += i->second;
    }
    if (i->second > 1) {
      gg += ncr(i->second, 2);
    }
  }
  cout << gg << endl;
  return 0;
}
