#include <bits/stdc++.h>
using namespace std;
int a[200005], b[200005];
map<long long, int> mp;
int main() {
  int n;
  cin >> n;
  long long sum = 0;
  mp[0] = 0;
  int num = -1;
  long long aum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
    if (mp[sum] || sum == 0) {
      num = max(num, mp[sum]);
    }
    aum = aum + i - num - 1;
    mp[sum] = i;
  }
  cout << aum << endl;
  return 0;
}
