#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const int N_MAX = 200000;
array<array<ll, 3>, N_MAX> C;
void comb_table(int N) {
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= 2; j++) {
      if (j == 0 || j == i)
        C[i][j] = 1LL;
      else
        C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
    }
  }
}
map<ll, int> A;
template <class T>
void gc(T &x) {
  char c;
  int s = 0;
  x = 0;
  c = getchar_unlocked();
  if (c == '-')
    s = 1;
  else if ('0' <= c && c <= '9')
    x = c - '0';
  while (true) {
    c = getchar_unlocked();
    if (c < '0' || '9' < c) break;
    x = x * 10 + (c - '0');
  }
  if (s) x = -x;
}
int main() {
  int N;
  gc(N);
  comb_table(N);
  ll suma = 0;
  A[suma]++;
  for (int i = (0); i < (N); ++i) {
    ll a;
    gc(a);
    suma += a;
    A[suma]++;
  }
  ll cnt = 0;
  for (auto &&a : A)
    if (1 < a.second) cnt += C[a.second][2];
  cout << cnt << endl;
  return 0;
}
