#include <bits/stdc++.h>
using namespace std;
int main(void) {
  map<long long int, int> unko;
  unko[0] = 1;
  int N;
  scanf("%d", &N);
  long long int sum[N];
  for (int i = 0; i < N; i++) sum[i] = 0;
  for (int i = 0; i < N; i++) {
    long long int po;
    scanf("%lld", &po);
    if (i == 0)
      sum[i] = po;
    else
      sum[i] = sum[i - 1] + po;
    unko[sum[i]]++;
  }
  long long int ans = 0;
  for (auto itr = unko.begin(); itr != unko.end(); ++itr) {
    if (itr->second >= 1) ans += (itr->second) * (itr->second - 1) / 2;
  }
  printf("%lld", ans);
  return 0;
}
