#include <bits/stdc++.h>
using namespace std;
int n, m;
int c[5001], l[5001], r[5001];
void solve() {
  for (int i = 0; i < n; ++i) {
    if (l[i] != r[i]) continue;
    for (int j = 0; j < n; ++j) {
      if (l[i] != r[j] && r[i] != l[j]) {
        swap(l[i], l[j]);
        break;
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &c[i]);
    l[i] = r[i] = c[i];
  }
  solve();
  int ans = 0;
  for (int i = 0; i < n; ++i) ans += l[i] != r[i];
  printf("%d\n", ans);
  for (int i = 0; i < n; ++i) printf("%d %d\n", l[i], r[i]);
  return 0;
}
