#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
int T, n, a[N];
map<long long, long long> mp;
long long sum, ans;
int main() {
  scanf("%d", &n);
  mp[0] = 0;
  long long last = -1;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    sum += x;
    if (mp.count(sum)) last = max(last, mp[sum]);
    ans += (i - last - 1);
    mp[sum] = i;
  }
  printf("%lld\n", ans);
}
