#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, a, b, x, y, z, n, mx, mn, tmp;
  int cnt = 0, ans = 0;
  string s = "";
  vector<int> vc;
  map<int, int> mp;
  map<char, int> mc;
  scanf("%d", &x);
  char ch, ch2;
  scanf("%d", &y);
  tmp = y;
  mx = y;
  for (int j = 1; j < x; j++) {
    scanf("%d", &y);
    if (y < mx) ans += abs(y - mx);
    mx = max(mx, y);
    printf("%d %d\n", mx, ans);
  }
  printf("%d\n", ans);
  return 0;
}
