#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll factorial(int i) {
  if (i == 0) return 1;
  return (factorial(i - 1)) * i;
}
int main() {
  int n;
  cin >> n;
  vector<ll> rui(n + 1);
  rui[0] = 0;
  for (int i = 1; i <= (int)(n); i++) {
    int a;
    cin >> a;
    rui[i] += rui[i - 1] + a;
  }
  sort(rui.begin(), rui.end());
  ll ans = 0;
  int count;
  for (int i = 0; i < (int)(n); i++) {
    count = 1;
    if (rui[i] == rui[i + 1]) {
      do {
        count++;
        i++;
      } while (rui[i] == rui[i + 1]);
      ans += count * (count - 1) / 2;
    }
  }
  cout << ans << endl;
}
