#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0), ios::sync_with_stdio(false);
  int n;
  cin >> n;
  long long a[n];
  for (int i = (0); i < (n); ++i) cin >> a[i];
  for (int i = (1); i < (n); ++i) a[i] += a[i - 1];
  sort(a, a + n);
  long long ans = 0, kpa = 0, cnt = 0;
  for (int i = (0); i < (n); ++i) {
    if (kpa == a[i])
      ++cnt;
    else {
      ans += (cnt + 1) * cnt / 2;
      kpa = a[i];
      cnt = 0;
    }
  }
  ans += (cnt + 1) * cnt / 2;
  cout << ans << endl;
  return 0;
}
