#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N + 1);
  B.at(0) = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    B.at(i + 1) = B.at(i) + A.at(i);
  }
  map<int, int> cnt;
  for (int i = 0; i <= N; i++) {
    int num = B.at(i);
    if (cnt.count(num)) {
      cnt.at(num)++;
    } else {
      cnt[num] = 1;
    }
  }
  long result = 0;
  for (pair<int, int> p : cnt) {
    result += p.second * (p.second - 1) / 2;
  }
  cout << result << endl;
  return 0;
}
