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