#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<double> A(N);
  for (int(i) = 0; (i) < (N); (i)++) cin >> A[i];
  vector<double> ruiseki(N, 0);
  map<double, int> mp;
  for (int(i) = 0; (i) < (N); (i)++) {
    ruiseki[i] = A[i];
    if (i > 0) ruiseki[i] += ruiseki[i - 1];
    mp[ruiseki[i]]++;
  }
  double ans = 0;
  for (auto entry : mp) {
    ans += (double)entry.second * (entry.second - 1) / 2;
  }
  ans += mp[0];
  cout << ans << endl;
  return 0;
}
