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