#include <bits/stdc++.h>
using namespace std;
struct my_hash {
  unsigned long long operator()(unsigned long long x) const {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
};
const int maxn = 2e5 + 5;
long long a[maxn];
unordered_map<long long, int, my_hash> mp;
int main() {
  int n;
  cin >> n;
  long long ans = 0;
  long long pre = 0;
  mp[0] = 1;
  int q = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pre += a[i];
    ans += i - max(q, mp[pre]);
    q = max(q, mp[pre]);
    mp[pre] = i + 1;
  }
  cout << ans;
  return 0;
}
