#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> a(N + 1);
  cin >> a.at(1);
  int A;
  for (int i = 1; i < N; i++) {
    cin >> A;
    a.at(i + 1) = a.at(i) + A;
  }
  sort(a.begin(), a.end());
  int count = 0, ans = 0, k = a.at(0);
  for (int i = 0; i < N + 1; i++) {
    if (k == a.at(i))
      count++;
    else {
      ans += count * (count - 1) / 2;
      k = a.at(i);
      count = 1;
    }
  }
  if (a.at(N) == a.at(N - 1)) ans += count * (count - 1) / 2;
  cout << ans << endl;
}
