#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a;
  vector<long> sum;
  for (int i = (0); i < (int)(n); i += 1) {
    int num;
    cin >> num;
    a.push_back(num);
  }
  sum.push_back(0);
  long total = 0;
  long minim = 0, maxim = 0;
  for (int i = (0); i < (int)(n); i += 1) {
    total += a[i];
    sum.push_back(total);
    minim = min(minim, total);
    maxim = max(maxim, total);
  }
  sort(sum.begin(), sum.end());
  int cnt = 0, set = sum[0], seq = 1;
  for (int i = (1); i < (int)(n + 1); i += 1) {
    if (set == sum[i]) {
      seq++;
    } else {
      cnt += seq * (seq - 1) / 2;
      set = sum[i];
      seq = 1;
    }
  }
  cnt += seq * (seq - 1) / 2;
  cout << cnt << endl;
  return 0;
}
