#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long LINF = 1e18;
int mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  long long sum = 0, ans = 0;
  int mx = 0;
  map<long long, int> mp;
  mp[sum] = 1;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    sum += x;
    mx = max(mx, mp[sum]);
    ans += i - mx;
    mp[sum] = i + 1;
  }
  cout << ans << endl;
  return 0;
}
