#include <bits/stdc++.h>
using namespace std;
struct st {
  long long sum;
  int index;
  bool operator<(const st& right) const { return sum < right.sum; }
  bool operator==(const st& right) const { return sum == right.sum; }
};
int n;
long long a[100000 * 2], ans = 0;
vector<st> sums;
int main() {
  cin >> n;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    sums.push_back(st{sum, i});
  }
  sort(sums.begin(), sums.end());
  sum = 0;
  for (int i = 0; i <= n; i++) {
    vector<st>::iterator low =
        lower_bound(sums.begin(), sums.end(), st{sum, 0});
    while (true) {
      if (low == sums.end() || (*low).sum > sum) break;
      if ((*low).index < i) {
        ++low;
        continue;
      }
      ++low;
      ans++;
    }
    sum += a[i];
  }
  cout << ans << endl;
}
