#include <bits/stdc++.h>
using namespace std;
int N;
map<long long, int> cnt;
int main() {
  cin >> N;
  long long cumsum = 0;
  cnt[0] = 1;
  for (int i = 0; i < N; ++i) {
    int ai;
    cin >> ai;
    cumsum += ai;
    if (cnt.find(cumsum) != cnt.end()) {
      cnt[cumsum]++;
    } else {
      cnt[cumsum] = 1;
    }
  }
  long long ans = 0;
  for (auto p : cnt) {
    int cnt = p.second;
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
}
