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