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