#include <bits/stdc++.h>
using namespace std;
int com(int a) { return (a == 0) ? 0 : (a * (a - 1)) / 2; }
int main() {
  int NNN;
  cin >> NNN;
  int temp;
  int a[NNN + 1];
  a[0] = 0;
  vector<int> sum;
  for (int i = 0; i < NNN; i++) {
    cin >> a[i + 1];
    a[i + 1] += a[i];
    sum.push_back(a[i + 1]);
  }
  sort(sum.begin(), sum.end());
  temp = (1 << 29);
  int count = 1;
  int anscount = 0;
  for (int i = 0; i < NNN; i++) {
    if (i == 0) {
      temp = sum[0];
      continue;
    } else if (temp == sum[i]) {
      count++;
    } else if (temp != sum[i]) {
      anscount += com(count);
      if (temp == 0) {
        anscount += count;
      }
      temp = sum[i];
      count = 1;
    }
  }
  anscount += com(count);
  if (temp == 0) anscount += count;
  cout << anscount << endl;
  return 0;
}
