#include <bits/stdc++.h>
using namespace std;
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);
  S[0] = 0;
  for (int i = 1; i <= N; i++) {
    S[i] = S[i - 1] + a[i - 1];
  }
  sort(S.begin(), S.end());
  long long res = 0;
  long long now = S[0];
  long long sum = 1;
  long long vres = 1;
  for (long long i = 1; i < (long long)S.size(); i++) {
    if (now == S[i]) {
      sum++;
      vres *= (sum - 1);
    } else {
      if (sum >= 2) {
        res += vres;
      }
      vres = 1;
      sum = 1;
      now = S[i];
    }
  }
  if (sum >= 2) {
    res += vres;
  }
  cout << res << endl;
  return 0;
}
