#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int a[N];
int n;
long long ans;
long long sum[N];
map<int, int> s;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
  s[0] = 1;
  for (int i = 1; i <= n; i++) {
    if (s.find(sum[i]) != s.end()) ans += s[sum[i]];
    s[sum[i]]++;
  }
  printf("%lld\n", ans);
  return 0;
}
