#include <iostream>
#include <algorithm>
#define N 1000001
using namespace std;
typedef pair<int, int> soldier;
soldier a[N];
bool cmp(soldier x, soldier y){
if (x.first==y.first){
return x.second<y.second;
}
else {
return x.first<y.first;
}
}
int main(){
int n;
scanf("%d", &n);
for (int i=0, x; i<n; i++){
scanf("%d", &x);
a[i]={0, x};
}
a[0].first=a[0].second;
a[n-1].first=a[n-1].second;
for (int i=1; i<n-1; i++){
a[i].first=a[i-1].second+a[i+1].second;
}
sort(a, a+n, cmp);
for (int i=0; i<n; i++){
printf("%d %d\n", a[i].first, a[i].second);
}
}