#include <bits/stdc++.h> using namespace std; int main(){ int n,tmp; vector<int> dp,data; while(cin>>n){ if(n == 0) break; for(int i = 1; i <= n; i++){ cin>>tmp; dp.push_back(tmp); data.push_back(tmp); } int len = dp.size(); for(int i = 1; i <= len; i++){ if(dp[i-1] > 0) dp[i] += dp[i-1]; } int end = max_element(dp.begin(),dp.end()) - dp.begin(); // cout<<dp[end]; int begin = end; tmp = dp[end]; if(tmp >= 0){ while(tmp != data[begin]){ tmp -= data[begin]; begin--; } cout<<dp[end]<<" "<<data[begin]<<" "<<data[end]<<endl; }else{ cout<<0<<" "<<data[0]<<" "<<data[n-1]<<endl; } dp.clear(); data.clear(); } }