#include <bits/stdc++.h>
using namespace std;
long long int mul(long long int a, long long int b, long long int c) {
  long long int res = (long long int)a * b;
  return (res >= c ? res % c : res);
}
template <typename T>
T mdpower(T e, T n, T m) {
  T x = 1, p = e;
  while (n) {
    if (n & 1) x = mul(x, p, m);
    p = mul(p, p, m);
    n >>= 1;
  }
  return x;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  t = 1;
  while (t--) {
    long long int n;
    cin >> n;
    long long int arr[n + 1];
    for (long long int i = 1; i <= n; i++) cin >> arr[i];
    long long int brr[n + 1];
    brr[0] = 0;
    for (long long int i = 1; i <= n; i++) brr[i] = brr[i - 1] + arr[i];
    long long int ans = 0;
    map<long long int, long long int> mp;
    long long int crr[n + 1];
    memset(crr, 0, sizeof crr);
    if (arr[1] != 0) {
      crr[1] = 1;
      mp[brr[1]] = 1;
    }
    if (arr[1] == 0) {
      mp[0] = 1;
      crr[1] = 2;
    }
    for (long long int i = 2; i <= n; i++) {
      long long int x = brr[i];
      if (mp.count(x) != 0) {
        crr[i] = max(crr[i - 1], mp[x] + 2);
        mp[x] = i;
      } else {
        if (x == 0) {
          crr[i] = max(crr[i - 1], 2LL);
          mp[x] = i;
          continue;
        }
        mp[x] = i;
        crr[i] = crr[i - 1];
      }
    }
    ans = 0;
    for (long long int i = 1; i <= n; i++) ans += i - crr[i] + 1;
    cout << ans << "\n";
  }
}
