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