#include <bits/stdc++.h>
using namespace std;
long long int temp[200000];
long long int cmb(long long int i, long long int n) {
  return temp[n] / temp[n - i] / temp[i];
}
int main(int argc, char const* argv[]) {
  temp[0] = 1;
  for (int t = 1; t < 200000; t++) {
    temp[t] = temp[t - 1] * t;
  }
  long long int N;
  cin >> N;
  vector<long long int> A(N);
  vector<long long int> S(N + 1);
  for (size_t i = 0; i < A.size(); i++) {
    cin >> A[i];
    if (i == 0) {
      S[0] = 0;
    } else {
      S[i] = S[i - 1] + A[i - 1];
    }
  }
  S[N] = S[N - 1] + A.back();
  long long int ans = 0;
  map<long long int, long long int> S_count;
  bool flag = true;
  for (size_t i = 0; i < S.size(); i++) {
    S_count[S[i]]++;
    if (S_count[S[i]] != 1) flag = flag;
  }
  if (flag) {
    cout << 0 << endl;
    return 0;
  }
  long long int key, value;
  for (const auto& [key, value] : S_count) {
    ans += cmb(2, value);
  }
  cout << ans << endl;
  return 0;
}
