#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, c[1000000], count = 1;
  cin >> n;
  cin >> c[1];
  for (int i = 1; i < n; i++) {
    cin >> a;
    if (a > c[count]) {
      count++;
      c[count] = a;
      cout << a << ' ' << count << endl;
    } else {
      for (int t = 1; t <= count; t++) {
        if (c[t] > a) {
          c[t] = a;
          break;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}
