#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, i;
  long long int a;
  vector<long long int> v;
  v.push_back(0LL);
  cin >> n;
  for (i = 0; i < n; ++i) {
    cin >> a;
    v.push_back(v[i] + a);
  }
  sort(v.begin(), v.end());
  a = -(n + 1);
  for (i = 0; i <= n; ++i) {
    a += (long long int)(upper_bound(v.begin(), v.end(), v[i]) -
                         lower_bound(v.begin(), v.end(), v[i]));
  }
  cout << a << endl;
  return 0;
}
