#include<cstdio>
#include<iostream>
#include<algorithm>
typedef long long ll;
using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N,ans = 0;
  cin >> N;
  ll num;
  ll t[N+1]={};
  for (int i = 1; i < N+1; i++){
    cin >> num;
    t[i] += t[i-1] + num;
  }
  sort(t,t+N+1);
  for(int i=0;i<N+1;i++){
    cout<<t[i]<<"\n";
  }
  for(int i=0;i<N;i++){
    for(int j=i+1;j<=N;j++){
      if(t[i]==t[j]) ans++;
    }
  }
  cout << ans;
  return 0;
}