#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const int N = 200000 + 20;
const int INF = 0x3f3f3f3f;
int n, a[N];
long long sum[N];
map<int, int> cnt;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    sum[i] = sum[i - 1] + a[i];
  }
  for (int i = 0; i <= n; ++i) {
    cnt[sum[i]]++;
  }
  long long ans = 0;
  for (const auto& kv : cnt) {
    if (kv.second > 1) {
      long long x = kv.second;
      ans += x * (x - 1) / 2LL;
    }
  }
  printf("%lld\n", ans);
}
