#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) {
    return a;
  }
  int r = a % b;
  return gcd(b, r);
}
int main() {
  long long n;
  cin >> n;
  vector<long long> s(n + 1, 0);
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    s[i + 1] = s[i] + a;
  }
  sort(s.begin(), s.end());
  long long ans = 0;
  long long st = 0;
  int ba = s[0];
  for (long long i = 1; i <= n; i++) {
    if (s[i] != ba) {
      st = i;
      ba = s[i];
    }
    ans += i - st;
  }
  cout << ans << endl;
}
