#include <bits/stdc++.h>
using namespace std;
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 += cnt * (cnt - 1) / 2;
      cnt = 1;
      mem = s[i];
    }
  }
  if (cnt >= 2) ans += cnt * (cnt - 1) / 2;
  printf("%lld", ans);
}
