#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long B = 0;
  long long M = 0;
  cin >> N;
  vector<long long> vec(N);
  vector<long long> v(N);
  for (int X = 0; X < N; X++) {
    cin >> vec.at(X);
    M += vec.at(X);
    v.at(X) = M;
  }
  sort(v.begin(), v.end());
  for (int X = 0; X < N; X++) {
    for (int Y = X; Y >= 0; Y--) {
      if (vec.at(X) == vec.at(Y)) {
        B++;
      }
    }
  }
  cout << B << endl;
}
