#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a;
  for (int i = 0; i < n; ++i) {
    long long tmp;
    std::cin >> tmp;
    a.push_back(tmp);
  }
  multiset<long long> sm{};
  long long sum = 0;
  sm.insert(0);
  long long ans = 0;
  for (int j = 0; j < n; ++j) {
    sum += a[j];
    long long ct = sm.count(sum);
    if (ct > 0) {
      ans += ct;
    }
    sm.insert(sum);
  }
  cout << ans << endl;
}
