#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
int sum=0;
int min1=INT_MAX, min2=INT_MAX;
vector<vector<int>>v;
vector<int>temp;
sum=sum+a[0];
temp.push_back(a[0]);
for(int i=1;i<n;i++){
if(a[i]-a[i-1]==1){
sum=sum+a[i];
temp.push_back(a[i]);
min2=min(min2,sum);
}
else{
if(temp.size() >= 2 && min2 < min1){
min1=min2;
// if(v.size() > 0){
// v.clear();
// }
v.push_back(temp);
temp.clear();
sum=0;
sum=sum+a[i];
temp.push_back(a[i]);
}
else{
if(temp.size()>0){
temp.clear();
sum=0;
sum=sum+a[i];
temp.push_back(a[i]);
}
}
}
}
for(int i=0;i<v.size();i++){
for(int j=0;j<v[i].size();j++){
cout<<v[i][j]<<" ";
}
cout<<"\n";
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IG1haW4oKXsKCWludCBuOwoJY2luPj5uOwoJaW50IGFbbl07Cglmb3IoaW50IGk9MDtpPG47aSsrKXsKCQljaW4+PmFbaV07Cgl9CglpbnQgc3VtPTA7CglpbnQgbWluMT1JTlRfTUFYLCBtaW4yPUlOVF9NQVg7Cgl2ZWN0b3I8dmVjdG9yPGludD4+djsKCXZlY3RvcjxpbnQ+dGVtcDsKCXN1bT1zdW0rYVswXTsKCXRlbXAucHVzaF9iYWNrKGFbMF0pOwoJZm9yKGludCBpPTE7aTxuO2krKyl7CgkJaWYoYVtpXS1hW2ktMV09PTEpewoJCQlzdW09c3VtK2FbaV07CgkJCXRlbXAucHVzaF9iYWNrKGFbaV0pOwoJCQltaW4yPW1pbihtaW4yLHN1bSk7CgkJfQoJCWVsc2V7CgkJCWlmKHRlbXAuc2l6ZSgpID49IDIgJiYgbWluMiA8IG1pbjEpewoJCQkJbWluMT1taW4yOwoJCQkJLy8gaWYodi5zaXplKCkgPiAwKXsKCQkJCS8vIA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