#include <bits/stdc++.h>
using namespace std;
vector<long long> a;
int d[200000] = {1}, n;
int main() {
  int i, j;
  int n;
  long long sum = 0, num = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    long long m;
    cin >> m;
    a.push_back(m);
  }
  for (i = 0; i < n; i++) {
    num += a[i];
    if (d[num] != 0) {
      sum += d[num];
      d[num]++;
    } else
      d[num] = 1;
  }
  cout << sum << endl;
  return 0;
}
