#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long int> S, uniS;
  S.push_back(0);
  long long int sum = 0;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    sum += tmp;
    S.push_back(sum);
  }
  sort(S.begin(), S.end());
  uniS = S;
  uniS.erase(unique(uniS.begin(), uniS.end()), uniS.end());
  int counter = 0;
  for (auto itr = uniS.begin(); itr != uniS.end(); itr++) {
    int n = count(S.begin(), S.end(), *itr);
    if (n < 2) {
      continue;
    } else {
      counter += n * (n - 1) / 2;
    }
  }
  std::cout << counter << std::endl;
}
