#include <bits/stdc++.h>
using namespace std;
void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}
void 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] = 0ll;
  for (int i = 0; i < n; ++i) s[i + 1] = s[i] + a[i];
  sort(s.begin(), s.end());
  int ans = 0;
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n + 1; ++j)
      if (s[i] == s[j]) ans++;
  cout << ans << endl;
}
int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}
