#include <bits/stdc++.h>
using namespace std;
void mahakal() {}
long long dx[4] = {1, 0, -1, 0};
long long dy[4] = {0, 1, 0, -1};
char c[4] = {'D', 'R', 'U', 'L'};
const long long maxN = 2e5 + 5;
long long n, m;
long long a[maxN];
void solve() {
  cin >> n;
  long long ans = 0, sum = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i + 1];
    a[i + 1] += a[i];
  }
  set<long long> st;
  st.insert(0);
  long long l = 1, r = 1;
  while (l <= n) {
    while (r <= n && !st.count(a[r])) {
      st.insert(a[r]);
      r++;
    }
    ans += (r - l);
    st.erase(a[l - 1]);
    l++;
  }
  cout << ans << endl;
}
int main() {
  mahakal();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t = 1;
  while (t--) solve();
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
  return 0;
}
