#include <bits/stdc++.h>
using namespace std;
map<long long, int> cnt;
const int MAXN = 1e5;
int n;
int a[MAXN + 5];
int main() {
  scanf("%d", &n);
  long long sum = 0LL, ans = 0LL;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum = sum + (long long)a[i];
    if (sum == 0LL) ans++;
    ans += 1LL * cnt[sum];
    cnt[sum]++;
  }
  printf("%lld\n", ans);
  return 0;
}
