#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, curr;
int a[maxn], cnt[maxn];
long long s[maxn], t[maxn], ans;
int main() {
  scanf("%d", &n);
  for (register int i = 1; i <= n; ++i)
    scanf("%d", &a[i]), s[i] = s[i - 1] + a[i], t[i] = s[i];
  sort(s + 1, s + 1 + n);
  for (int i = 1; i <= n; ++i)
    if (s[i] != 0) {
      ans += i - 1;
      break;
    }
  int sz = unique(s + 1, s + 1 + n) - s - 1;
  for (register int i = n; i >= 1; --i) {
    int pos = lower_bound(s + 1, s + 1 + sz, t[i]) - s;
    ans += cnt[pos];
    ++cnt[pos];
  }
  cout << ans << endl;
}
