#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long inv[1000000];
long long FactorialInv[1000000];
long long Factorial[1000000];
long long beki(long long a, long long b) {
  if (b == 0) {
    return 1;
  }
  long long ans = beki(a, b / 2);
  ans = ans * ans % mod;
  if (b % 2 == 1) {
    ans = ans * a % mod;
  }
  return ans;
}
void init_combination() {
  inv[1] = 1;
  FactorialInv[1] = 1;
  Factorial[1] = 1;
  for (int i = 2; i < 1000000; i++) {
    inv[i] = beki(i, mod - 2);
    Factorial[i] = Factorial[i - 1] * i % mod;
    FactorialInv[i] = FactorialInv[i - 1] * inv[i] % mod;
  }
}
long long combination(long long a, long long b) {
  if ((a == b) || (b == 0)) {
    return 1;
  }
  if (a < b) return 0;
  long long ans = Factorial[a] * FactorialInv[b] % mod;
  ans = ans * FactorialInv[a - b] % mod;
  return ans;
}
int main() {
  init_combination();
  long long N;
  cin >> N;
  long long a[200050];
  for (int i = 1; i <= N; i++) cin >> a[i];
  vector<long long> sum;
  sum.push_back(a[1]);
  map<long long, long long> mp;
  for (int i = 2; i <= N; i++) {
    sum.push_back(sum.back() + a[i]);
  }
  sum.push_back(0);
  mp[0]++;
  for (int i = 0; i < N; i++) mp[sum[i]]++;
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    ans += combination(mp[sum[i]], 2);
    mp[sum[i]] = 0;
  }
  cout << ans << endl;
  return 0;
}
