#include <bits/stdc++.h>
using namespace std;
int N;
long long A[200000];
long long cnt[200001];
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%lld", &A[i]);
  cnt[0] = 0;
  for (int i = 0; i < N; i++) cnt[i + 1] = cnt[i] + A[i];
  sort(cnt, cnt + N + 1);
  long long ans = 0;
  auto i = cnt;
  while (i < cnt + N + 1) {
    int count =
        upper_bound(cnt, cnt + N + 1, *i) - lower_bound(cnt, cnt + N + 1, *i);
    ans += count * (count - 1) / 2;
    i = upper_bound(cnt, cnt + N + 1, *i);
  }
  cout << ans << endl;
  return 0;
}
