#include <bits/stdc++.h>
using namespace std;
long long n, a[400010], sum[400040];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    sum[i] = sum[i - 1] + a[i];
  }
  sort(sum + 1, sum + n + 1);
  long long ans = 0, tmp = 1, tt = 0;
  for (int i = 1; i <= n; i++) {
    if (sum[i] == sum[i - 1]) {
      tmp++;
      continue;
    } else
      ans += (tmp * tmp - tmp) / 2, tmp = 1;
  }
  ans += (tmp * tmp - tmp) / 2;
  cout << ans + tt;
  return 0;
}
