#include <bits/stdc++.h>
using namespace ::std;
int main() {
  int N;
  cin >> N;
  vector<long long> A(N + 1, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<long long> acc(N + 1, 0);
  long long ans = 0;
  for (int i = 0; i < N; i++) acc[i + 1] = acc[i] + A[i];
  for (int l = 0; l < N; l++) {
    for (int r = l + 1; r <= N; r++) {
      long long s = acc[r] - acc[l];
      if (s == 0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
