#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A[200000];
  int cs[200000 + 1];
  map<int, int> mp;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  cs[0] = 0;
  for (int i = 1; i < N + 1; i++) cs[i] = cs[i - 1] + A[i - 1];
  for (int i = 0; i < N + 1; i++) mp[cs[i]]++;
  int res = 0;
  for (auto item = mp.begin(); item != mp.end(); ++item) {
    int tmp = item->second;
    res += tmp * (tmp - 1) / 2;
  }
  cout << res << endl;
  return 0;
}
