#include <bits/stdc++.h>
using namespace std;
long long int ans;
long long int n, tot, a[200010], sum[200010], c[200010], numc[200010];
void lisanhua() {
  sort(sum + 1, sum + 1 + n);
  for (int i = 1; i <= n; i++)
    if (sum[i] != sum[i - 1]) {
      c[++tot] = sum[i];
      numc[tot]++;
    } else
      numc[tot]++;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum[i] = sum[i - 1] + a[i];
  }
  lisanhua();
  for (int i = 1; i <= tot; i++)
    ans += (long long int)(numc[i] * (numc[i] - 1)) / 2;
  if (ans != 0) cout << ans;
  return 0;
}
