#include <bits/stdc++.h>
using namespace std;
map<long long, long long> cnt;
const int maxn = 1e5 + 10;
long long a[maxn], sum[maxn];
int main() {
  int N;
  long long ans = 0;
  scanf("%d", &N);
  cnt[0]++;
  for (int i = 1; i <= N; ++i) {
    scanf("%lld", a + i), sum[i] = sum[i - 1] + a[i];
    ans += cnt[sum[i]];
    cnt[sum[i]]++;
  }
  printf("%lld\n", ans);
  return 0;
}
