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