#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
unsigned long long gcd(unsigned long long a, unsigned long long b) {
  return b ? gcd(b, a % b) : a;
}
unsigned long long lcm(unsigned long long a, unsigned long long b) {
  return a / gcd(a, b) * b;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0, i_len = (n); i < i_len; i++) cin >> a[i];
  vector<ll> b(n + 1);
  for (int i = 0, i_len = (n); i < i_len; i++) b[i + 1] = b[i] + a[i];
  map<ll, int> cnt;
  for (int i = 1, i_len = (n); i <= i_len; i++) cnt[b[i]]++;
  ll ans = 0;
  for (auto p : cnt) {
    if (p.first == 0) ans += p.second;
    if (p.second <= 1) continue;
    ans += p.second * (p.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
