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