#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll INF = 1LL << 20;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
  int N;
  cin >> N;
  vector<ll> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec[i];
  }
  vector<ll> sum(N + 1);
  sum[0] = 0;
  for (int i = 0; i < N + 1; i++) {
    sum[i + 1] = sum[i] + vec[i];
  }
  {
    for (int i = 0; i < sum.size(); i++) {
      cout << sum[i] << " ";
    }
    cout << endl;
  };
  map<ll, int> mp;
  int cnt = 0;
  for (int i = 0; i < N + 1; i++) {
    mp[sum[i]]++;
  }
  map<ll, int>::iterator itr;
  for (itr = mp.begin(); itr != mp.end(); itr++) {
    ll a = itr->second;
    cnt += ((a - 1) * a) / 2;
  }
  cout << cnt << endl;
  return 0;
}
