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