#include <bits/stdc++.h>
using namespace std;
vector<int> v[666017];
vector<long long> v1[666017];
int n, i, x;
long long y, s, nr;
void u(long long y) {
  int i, k;
  long long m;
  m = (1LL) * y % 666013;
  if (m < 0) m += 666013;
  k = v[m].size();
  k--;
  for (i = 0; i <= k; i++) {
    if (v[m][i] == y) {
      nr = (0LL) + nr + v1[m][i];
      v1[m][i]++;
      return;
    }
  }
  v[m].push_back(y);
  v1[m].push_back(1);
}
int main() {
  scanf("%d", &n);
  v[0].push_back(0);
  v1[0].push_back(1);
  s = 0LL;
  nr = 0LL;
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    s = (0LL) + s + x;
    u(s);
  }
  printf("%lld\n", nr);
  return 0;
}
