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