#include <bits/stdc++.h>
using namespace std;
long long comb(long long x, long long y) {
  long long tmp = 1;
  for (int i = 0; i < y; i++) tmp = tmp * (x - i) / (i + 1);
  return tmp;
}
int main() {
  long long N;
  cin >> N;
  vector<long long> a(N + 1, 0);
  vector<long long> s(N + 1, 0);
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
    s[i] = s[i - 1] + a[i];
  }
  sort(s.begin(), s.end());
  long long mem = 0, cnt = 1;
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    if (s[i] == mem)
      cnt++;
    else {
      if (cnt >= 2) ans += comb(cnt, 2);
      cnt = 1;
      mem = s[i];
    }
  }
  if (cnt >= 2) ans += comb(cnt, 2);
  printf("%lld", ans);
}
