#include <bits/stdc++.h>
using namespace std;
vector<long long> CUMSUM(vector<long long> A) {
  auto R = vector<long long>(A.size() + 1);
  R[0] = 0;
  for (int i = 0; i <= A.size(); i++) {
    R[i] = R[i - 1] + A[i - 1];
  }
  return R;
}
int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (long long &i : A) cin >> i;
  auto C = CUMSUM(A);
  map<long long, int> M;
  for (long long &i : C) {
    M[i]++;
  }
  int res = 0;
  for (auto &i : M) {
    res += i.second * (i.second - 1) / 2;
  }
  cout << res << endl;
}
