#include <bits/stdc++.h>
using namespace std;
int N;
int A[20100];
long long sum = 0;
int main() {
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    cin >> A[i];
    A[i] += A[i - 1];
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; i + j <= N + 1; ++j) {
      if (A[i + j - 1] - A[j - 1] == 0) {
        ++sum;
      }
    }
  }
  cout << sum << endl;
}
