#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<ll> count(N + 1);
  map<ll, ll> mp;
  count[0] = 0;
  for (ll i = 0; i < N; i++) {
    count[i + 1] = count[i] + A[i];
  }
  for (ll i = 0; i < N + 1; i++) {
    mp[count[i]]++;
  }
  int ans = 0;
  for (auto x : mp) {
    auto value = x.second;
    ans += value * (value - 1) / 2;
  }
  cout << ans << endl;
}
