#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';
void solve();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(numeric_limits<double>::max_digits10);
  solve();
  return 0;
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  map<ll, int> m;
  m[0]++;
  ll sum = 0;
  for (int i = (0); i < ((n)); i++) {
    cin >> a[i];
    sum += a[i];
    m[sum]++;
  }
  ll ans = 0;
  for (auto x : m) {
    int z = x.second;
    ans += z * (z - 1) / 2;
  }
  cout << ans << EOL;
}
