#include <bits/stdc++.h>
using namespace std;
bool is_prime(long long int x) {
  for (long long int i = 2; i * i <= x; i++) {
    if (x % i == 0) return false;
  }
  return true;
}
int main() {
  long long int A, B, C = 999999999, D = 0, E = 0, F = 0, G = 0, H = 0, N, M;
  string S, K, L;
  cin >> N;
  vector<long long int> P(N, 0), Q(N, 0);
  for (long long int i = 0; i < N; i++) cin >> P[i];
  Q[0] = P[0];
  for (long long int i = 1; i < N; i++) Q[i] = P[i] + Q[i - 1];
  for (long long int i = 0; i < N; i++)
    for (long long int j = i + 1; j < N; j++)
      if (Q[i] == Q[j]) D++;
  for (long long int i = 0; i < N; i++)
    if (Q[i] == 0) D++;
  cout << D << endl;
}
