#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<int> cs(N + 1, 0);
  for (int i = 0; i < N; i++) cs.at(i + 1) = cs.at(i) + A.at(i);
  sort(cs.begin(), cs.end(), [](int l, int r) -> bool { return l > r; });
  cs.erase(find(cs.begin(), cs.end(), 0));
  ll res = count(cs.begin(), cs.end(), 0);
  int prev, cnt = 0;
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      prev = cs.at(i);
      cnt = 1;
    } else if (cs.at(i) == prev) {
      cnt++;
      if (i == N - 1) {
        res += cnt * (cnt - 1) / 2;
      }
    } else {
      if (cnt > 1) res += cnt * (cnt - 1) / 2;
      prev = cs.at(i);
      cnt = 1;
    }
  }
  cout << res << endl;
}
