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