#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, co = 0;
  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);
  }
  sort(B.begin(), B.end());
  int tmp = 1;
  for (int i = 0; i < N; i++) {
    if (B.at(i) == B.at(i + 1)) {
      tmp++;
    } else {
      co += tmp * (tmp - 1) / 2;
      tmp = 1;
    }
  }
  if (tmp != 1) co += tmp * (tmp - 1) / 2;
  cout << co << endl;
}
