#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N;
ll A[101010];
map<ll, ll> memo;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  for (int j = 0; j < N; ++j) cin >> A[j];
  memo[0] = 1;
  ll ans = 0, acc = 0;
  for (int j = 0; j < N; ++j) {
    acc += A[j];
    ans += memo[acc];
    memo[acc]++;
  }
  cout << ans << endl;
  return 0;
}
