#include <bits/stdc++.h>
using namespace std;
signed main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; ++i) cin >> A[i];
  vector<long> S(n + 1, 0);
  for (int i = 0; i < n; ++i) S[i + 1] = S[i] + A[i];
  long 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;
}
