#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int ddx[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
bool debug = false;
const long long M = 998244353;
vector<long long> fac(300001);
vector<long long> ifac(300001);
long long mpow(long long x, long long n) {
  long long ans = 1;
  while (n != 0) {
    if (n & 1) ans = ans * x % M;
    x = x * x % M;
    n = n / 2;
  }
  return ans;
}
long long comb(long long a, long long b) {
  if (a == 0 && b == 0) return 1;
  if (a < b || a < 0) return 0;
  long long tmp = ifac[a - b] * ifac[b] % M;
  return tmp * fac[a] % M;
}
void init() {
  fac[0] = 1;
  ifac[0] = 1;
  for (long long i = 0; i < 20000; i++) {
    fac[i + 1] = fac[i] * (i + 1) % M;
    ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M;
  }
}
int main() {
  init();
  int N;
  cin >> N;
  vector<long long> A(N);
  map<long long, int> make_pair;
  make_pair[0]++;
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      make_pair[A[i]]++;
    } else {
      A[i] += A[i - 1];
      make_pair[A[i]]++;
      ;
    }
  }
  long long ans = 0;
  for (auto x : make_pair) {
    ans += comb(x.second, 2);
  }
  cout << ans << endl;
  return 0;
}
