#include <bits/stdc++.h>
using namespace std;
int a[200000];
int ruisekiwa[200001];
int main() {
  int N;
  cin >> N;
  long long reiwa = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  ruisekiwa[0] = 0;
  for (int i = 1; i <= N; i++) {
    ruisekiwa[i] = ruisekiwa[i - 1] + a[i - 1];
  }
  sort(ruisekiwa, ruisekiwa + N + 1);
  long long kazu = 1;
  for (int i = 0; i < N; i++) {
    if (ruisekiwa[i] == ruisekiwa[i + 1]) {
      kazu++;
    } else {
      reiwa += kazu * (kazu - 1) / 2;
      kazu = 1;
    }
  }
  reiwa += kazu * (kazu - 1) / 2;
  cout << reiwa << endl;
  return 0;
}
