#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a < b) {
    do {
      a = a ^ b;
      b = a ^ b;
      a = a ^ b;
    } while (0);
  }
  int r = a % b;
  if (r == 0) return b;
  return gcd(r, b);
}
int main() {
  long long int n, cnt = 0;
  cin >> n;
  vector<int> a, sum(n + 1, 0);
  for (int i = 0; i < n; i++) {
    long long int tmp;
    cin >> tmp;
    a.push_back(tmp);
    sum.at(i + 1) = sum.at(i) + a.at(i);
  }
  map<long long int, long long int> m;
  for (int i = 0; i < n + 1; i++) {
    cnt += m[sum.at(i)];
    m[sum.at(i)]++;
  }
  cout << cnt << endl;
  return 0;
}
