#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cnt = 0, memo = 0;
  cin >> n;
  int a[n], sum[n + 1];
  sum[0] = 0;
  for (int i = (0); i < (n); i++) {
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
  }
  sort(sum, sum + n + 1);
  for (int i = (1); i < (n + 1); i++) {
    memo++;
    if (sum[i] != sum[i - 1]) {
      if (memo > 1) {
        cnt += (memo) * (memo - 1) / 2;
      }
      memo = 0;
    }
  }
  memo++;
  if (memo > 1) {
    cnt += memo * (memo - 1) / 2;
  }
  cout << cnt << endl;
  return 0;
}
