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