#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int a[200001];
  vector<long long int> sum;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i == 0)
      sum.push_back(a[i]);
    else
      sum.push_back(sum[i - 1] + a[i]);
  }
  sort(sum.begin(), sum.end());
  int now = 0;
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += lower_bound(sum.begin(), sum.end(), now + 1) -
           lower_bound(sum.begin(), sum.end(), now);
    now += a[i];
    if (lower_bound(sum.begin(), sum.end(), now) != sum.end())
      sum.erase(lower_bound(sum.begin(), sum.end(), now));
  }
  cout << ans << endl;
  return 0;
}
