#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;
int main(void) {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  map<ll, ll> mp;
  ll sum = 0;
  mp[0] = 1;
  for (int i = 0; i < N; i++) {
    sum += A[i];
    if (mp.find(sum) != mp.end()) {
      mp[sum]++;
    } else {
      mp[sum] = 1;
    }
  }
  ll ans = 0;
  for (auto t : mp) {
    ans += t.second / 2 * (t.second - 1);
  }
  cout << ans << endl;
  return 0;
}
