#include <bits/stdc++.h>
using namespace std;
const int maxn = 200100;
const long long oo = 1e15;
int n;
long long a[maxn];
map<long long, int> cnt;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] = a[i - 1] + a[i];
    cnt[a[i] + oo]++;
  }
  long long ans = cnt[oo];
  for (int i = 1; i <= n; i++)
    if (cnt[a[i] + oo]) {
      ans += (cnt[a[i] + oo] - 1) * cnt[a[i] + oo] / 2;
      cnt[a[i] + oo] = 0;
    }
  cout << ans << endl;
}
