#include <bits/stdc++.h>
using namespace std;
int a[200005];
map<int, int> cnt;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  cnt[0] = 1;
  long long res = 0;
  long long cur = 0;
  for (int i = 0; i < n; i++) {
    cur += a[i];
    res += cnt[cur];
    cnt[cur]++;
  }
  printf("%lld\n", res);
}
