#include <bits/stdc++.h>
using namespace std;
using long long int = long long int;
using pii = pair<int, int>;
using pll = pair<long long int, long long int>;
using vi = vector<int>;
using vl = vector<long long int>;
using vii = vector<pii>;
using vll = vector<pll>;
int main() {
  int N, K;
  scanf("%d", &N);
  vl a(N);
  vl s(N + 1, 0);
  for (long long int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
    a[i] -= K;
    s[i + 1] += s[i] + a[i];
  }
  sort(s.begin(), s.end());
  long long int tmp = 0;
  long long int cnt = 1;
  long long int ans = 0;
  for (long long int i = 1; i < N + 1; i++) {
    if (tmp == s[i])
      cnt++;
    else
      ans += cnt * (cnt - 1) / 2, tmp = s[i], cnt = 1;
  }
  if (cnt) ans += cnt * (cnt - 1) / 2;
  printf("%lld\n", ans);
  return 0;
}
