#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int MAX = 1e9;
int MOD = 1e9 + 7;
int main() {
  long long N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < (N); i++) cin >> A[i];
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    int left = i + 1;
    long long temp = A[i];
    temp += A[left];
    while (left <= N) {
      left++;
      temp += A[left];
      if (temp == 0) ans++;
    }
  }
  cout << ans << endl;
}
