#include <bits/stdc++.h>
using namespace std;
int n, a[200010];
long long sum = 0, ans = 0, cur = 0, cnt = 0;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i] += a[i - 1];
  }
  sort(a, a + n + 1);
  for (int i = 0; i <= n; i++) {
    if (a[i] == cur)
      cnt++;
    else {
      ans += cnt * (cnt - 1) / 2;
      cur = a[i], cnt = 1;
    }
  }
  ans += cnt * (cnt - 1) / 2;
  printf("%lld", ans);
}
