#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1.01e9;
const long double eps = 1e-9;
const long double pi = acos((long double)-1.0);
vector<pair<int, int> > ent;
int main() {
  cerr << "picanha\n";
  int n, lixo;
  scanf("%d %d", &n, &lixo);
  for (int i = 0; i < n; ++i) {
    int t;
    scanf("%d", &t);
    ent.push_back(make_pair(t, t));
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i != j) {
        if (ent[i].first != ent[j].second && ent[j].first != ent[i].second) {
          swap(ent[i].second, ent[j].second);
        }
      }
    }
  }
  int tot = 0;
  for (int i = 0; i < n; ++i) {
    if (ent[i].first != ent[i].second) tot++;
  }
  printf("%d\n", tot);
  for (int i = 0; i < n; ++i) {
    printf("%d %d\n", ent[i].first, ent[i].second);
  }
}
