#include <bits/stdc++.h>
using namespace std;
using llint = long long int;
int n;
vector<llint> vtotal;
int main() {
  llint ans = 0;
  cin >> n;
  vtotal.reserve(n + 1);
  llint total = 0;
  for (int i = 0; i < n; i++) {
    llint x;
    cin >> x;
    total += x;
    vtotal.push_back(total);
    if (total == 0) {
      ans++;
    }
  }
  for (int i = 0; i < n - 1; i++) {
    for (int p = i + 1; p < n; p++) {
      if (vtotal[i] == vtotal[p]) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
