#include <bits/stdc++.h>
using namespace std;
const long mod = 1e9 + 7;
const long long inf = 2e9 + 10;
template <typename T1, typename T2>
static void relax(T1 &x, T2 y) {
  if (x > y) x = y;
}
template <typename T1, typename T2>
static void gain(T1 &x, T2 y) {
  if (x < y) x = y;
}
long long powmod(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const int maxn = 2e5 + 5;
int n;
int a[maxn];
long long ps[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int(i) = 0; (i) < (int)(n); ++(i)) cin >> a[i];
  ps[0] = a[0];
  for (int(i) = (int)(1); (i) <= (int)(n - 1); ++(i)) ps[i] = ps[i - 1] + a[i];
  map<long long, int> ds;
  for (int(i) = 0; (i) < (int)(n); ++(i)) ds[ps[i]]++;
  long long ans = 0;
  for (int(i) = 0; (i) < (int)(n); ++(i)) {
    long long x = ds[ps[i]];
    ans += (x * (x - 1)) / 2;
  }
  cout << ans << "\n";
  return 0;
}
