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