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