#include <iostream>
#include <cassert>
#include <queue>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define int long long
#define pii pair<int, int>
#define eb emplace_back
#define F first
#define S second
#define test(x) cout << "Test: " << x << '\n'
#define debug puts("qwq");
#define open(x) freopen(#x".in", "r", stdin);freopen(#x".out", "w", stdout);
#define close fclose(stdin);fclose(stdout);
namespace FastIO {
template <typename T = int>
inline T read() {
T s = 0, w = 1;
char c = getchar();
while (!isdigit(c)) {
if (c == '-') w = -1;
c = getchar();
}
while (isdigit(c)) s = (s << 1) + (s << 3) + (c ^ 48), c = getchar();
return s * w;
}
template <typename T>
inline void read(T &s) {
s = 0;
int w = 1;
char c = getchar();
while (!isdigit(c)) {
if (c == '-') w = -1;
c = getchar();
}
while (isdigit(c)) s = (s << 1) + (s << 3) + (c ^ 48), c = getchar();
s = s * w;
}
template <typename T, typename... Arp> inline void read(T &x, Arp &...arp) {
read(x), read(arp...);
}
template <typename T>
inline void write(T x, char ch) {
if (x < 0) x = -x, putchar('-');
static char stk[25];
int top = 0;
do {
stk[top++] = x % 10 + '0', x /= 10;
} while (x);
while (top) putchar(stk[--top]);
putchar(ch);
return;
}
template <typename T>
inline void smax(T &x, T y) {
if (x < y) x = y;
}
template <typename T>
inline void smin(T &x, T y) {
if (x > y) x = y;
}
void quit() {
exit(0);
}
} using namespace FastIO;
signed main() {
int n = read();
set<pii> st;
st.insert({read(), 1});
for (int i = 2, x; i <= n; ++i) {
read(x);
auto qwq = st.lower_bound({x, 0});
if (qwq == st.begin()) printf("%lld %lld\n", abs(x - qwq->first), qwq->second);
else {
pii a = *qwq;
--qwq;
pii b = *qwq;
int val = 0;
if (abs(a.first - x) < abs(b.first - x)) {
val = a.first;
} else if (abs(a.first - x) == abs(b.first - x)) {
if ((*st.lower_bound({a.first,0})).second < (*st.lower_bound({b.first,0})).second) val = a.first;
else val = b.first;
} else {
val = b.first;
}
qwq = st.lower_bound({val, 0});
printf("%lld %lld\n", abs(x - qwq->first), qwq->second);
} st.insert({x, i});
}
return 0;
}