#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int a[200001];
  multiset<long long int> sum;
  long long int beforesum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i == 0)
      sum.insert(a[i]);
    else
      sum.insert(beforesum + a[i]);
    beforesum += a[i];
  }
  long long int now = 0;
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += sum.count(now);
    now += a[i];
    auto tmp = sum.find(now);
    if (tmp != sum.end()) sum.erase(tmp);
  }
  cout << ans << endl;
  return 0;
}
