#include <bits/stdc++.h>
using namespace std;
long long a[334334], cnt[334334];
long long n, memo = 0, ans = 0;
signed main() {
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++) {
    memo += a[i];
    cnt[i] = memo;
  }
  sort(cnt, cnt + n);
  for (long long i = 0; i < n; i++) {
    if (cnt[i] == cnt[i + 1]) continue;
    if (cnt[i] == 0)
      ans++;
    else {
      ans += (upper_bound(cnt, cnt + n, cnt[i]) -
              lower_bound(cnt, cnt + n, cnt[i])) *
             (upper_bound(cnt, cnt + n, cnt[i]) -
              lower_bound(cnt, cnt + n, cnt[i]) - 1) /
             2;
    }
  }
  cout << ans << endl;
}
