#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long> ar(n + 1);
  ar[0] = 0;
  for (int i = 1; i <= n; i++) {
    int tmp;
    cin >> tmp;
    ar[i] = ar[i - 1] + tmp;
  }
  map<long, int> rcnt;
  for (int i = 0; i <= n; i++) rcnt[ar[i]]++;
  int ret = 0;
  for (pair<int, int> p : rcnt) {
    long t = p.second;
    ret += (t * (t - 1)) / 2;
  }
  cout << ret;
  return 0;
}
