#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
int main() {
  int n;
  cin >> n;
  int an[n];
  for (int i = 0; i < (int)(n); i++) cin >> an[i];
  ll sn[n + 1];
  sn[0] = 0;
  for (int i = 0; i < (int)(n); i++) sn[i + 1] = sn[i] + an[i];
  sort(sn, sn + n + 1);
  int cnt = 0, total = 0;
  for (int i = 0; i < (int)(n); i++) {
    if (sn[i + 1] == sn[i]) {
      cnt++;
      total += cnt;
    } else {
      cnt = 0;
    }
  }
  cout << total;
}
