#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  int N;
  cin >> N;
  vector<long long> A(N), S(N);
  int i, j;
  for (i = 0; i < N; i++) {
    cin >> A[i];
    if (i == 0) {
      S[i] = A[i];
    } else {
      S[i] = S[i - 1] + A[i];
    }
  }
  long long aw = 0;
  for (i = 0; i < N; i++) {
    for (j = i + 1; j < N; j++) {
      if (S[j] == 0) {
        aw++;
      }
      S[j] -= A[i];
    }
  }
  cout << aw << endl;
  return 0;
}
