#include <bits/stdc++.h>
using namespace std;
const int N = 50;
int dp[N][2], num[N], n;
void go(int t, int from, int to, bool ok) {
  if (t == 0) return;
  if (num[t] == 0) {
    go(t - 1, from, to, ok);
    return;
  }
  int mid = 6 - from - to;
  if (!ok || num[t] == 1) {
    go(t - 1, from, mid, 0);
    for (int i = (1); i <= (num[t]); i++) printf("%d %d\n", from, to);
    go(t - 1, mid, to, 0);
  } else {
    go(t - 1, from, to, 0);
    for (int i = (1); i <= (num[t] - 1); i++) printf("%d %d\n", from, mid);
    if (dp[t - 1][1] == 0) {
      printf("%d %d\n", from, to);
      for (int i = (1); i <= (num[t] - 1); i++) printf("%d %d\n", mid, to);
    } else {
      printf("%d %d\n", from, mid);
      go(t - 1, to, from, 0);
      for (int i = (1); i <= (num[t]); i++) printf("%d %d\n", mid, to);
      go(t - 1, from, to, 1);
    }
  }
}
int main() {
  cin >> n;
  for (int i = (1); i <= (n); i++) {
    int x;
    scanf("%d", &x);
    num[x]++;
  }
  for (int i = (1); i <= (20); i++) {
    if (num[i] == 0) {
      dp[i][0] = dp[i - 1][0];
      dp[i][1] = dp[i - 1][1];
    } else {
      dp[i][0] = dp[i - 1][0] * 2 + num[i];
      if (num[i] == 1)
        dp[i][1] = dp[i][0];
      else {
        dp[i][1] = dp[i - 1][0] * 2 + dp[i - 1][1] + num[i] * 2;
        if (dp[i - 1][1] == 0) dp[i][1]--;
      }
    }
  }
  printf("%d\n", dp[20][1]);
  go(20, 1, 3, 1);
  return 0;
}
