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