#include <bits/stdc++.h>
#pragma warning(disable : 4996)
const long long MOD = 1000000007;
using namespace std;
int main(int argc, char* argv[]) {
  int n;
  scanf("%d", &n);
  long long sum = 0;
  int i;
  map<long long, int> cnt;
  cnt[0]++;
  for (i = 0; i < n; i++) {
    int tmp;
    scanf("%d", &tmp);
    sum += tmp;
    cnt[sum]++;
  }
  long long ans = 0;
  auto it = cnt.begin();
  for (; it != cnt.end(); ++it) {
    int tmp = it->second;
    ans += tmp * (tmp - 1) / 2;
  }
  printf("%lld\n", ans);
  return 0;
}
