#include <bits/stdc++.h>
using namespace std;
map<long long, long long> cnt;
long long n, a[100001], ans;
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    a[i] += a[i - 1];
    ans += cnt[a[i]]++;
  }
  printf("%lld", ans + cnt[0]);
  return 0;
}
