#include <bits/stdc++.h>
using namespace std;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a, cnt = 0, k;
  vector<long long> s;
  cin >> n;
  s.resize(n + 1);
  s[0] = 0;
  for (int i = 1; i < n + 1; i++) {
    cin >> a;
    s[i] = s[i - 1] + a;
  }
  sort(s.begin(), s.end());
  ;
  for (int i = 0; i < n + 1; i++) {
    if (i == 0 || s[i] > s[i - 1]) k = i;
    cnt += (i - k);
  }
  cout << cnt << '\n';
  return 0;
}
