#include <bits/stdc++.h>
const int inf = INT_MAX;
const int MAX = 1e6 + 9;
const long long MOD = 2e9 + 7;
const int TOT_PRIMES = 1e6 + 9;
const int MAX_A = 71;
const int LN = 20;
using namespace std;
int main() {
  int n;
  cin >> n;
  map<long long, long long> make_pair;
  make_pair[0] = 1;
  long long sum = 0;
  long long ans = 0;
  long long pos = 0;
  for (int i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    sum = sum + x;
    pos = max(pos, make_pair[sum]);
    ans = ans + (i - pos);
    make_pair[sum] = i + 1;
  }
  cout << ans;
}
