#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  cin >> n;
  vector<long long> vec(n + 1);
  long long ans = 0;
  long long cnt = 0;
  long long b = 0;
  vec.at(0) = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> vec.at(i);
    vec.at(i) += vec.at(i - 1);
  }
  sort(vec.begin(), vec.end());
  ;
  for (long long i = 0; i < n; i++) {
    if (vec.at(i + 1) == vec.at(i)) {
      cnt++;
    } else if (cnt) {
      ans += cnt * (cnt + 1) / 2;
      b = cnt;
      cnt = 0;
    } else {
      continue;
    }
  }
  if (b) {
    ans += b * (b + 1) / 2;
  }
  cout << ans << endl;
}
