#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long> a(N + 1);
  a[0] = 0;
  for (int i = 1; i < N + 1; i++) cin >> a[i];
  for (int i = 0; i < N; i++) a[i + 1] += a[i];
  sort(a.begin(), a.end());
  long long ans = 0;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (a[i + 1] == a[i])
      cnt++;
    else {
      if (cnt) {
        ans += (cnt + 1) * cnt / 2;
        cnt = 0;
      }
    }
  }
  if (cnt) ans += (cnt + 1) * cnt / 2;
  cout << ans << endl;
  return 0;
}
