#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  long long cnt = 0, sum_first = 0;
  for (int l = 1; l <= N; ++l) {
    sum_first += A[l - 1];
    long long sum = sum_first - A[l - 1];
    for (int i = l - 1; i < N; ++i) {
      sum += A[i];
      cnt += (sum == 0) ? 1 : 0;
      sum -= A[i - l + 1];
    }
  }
  cout << cnt << endl;
  return 0;
}
