#include <bits/stdc++.h>
using namespace std;
struct a1 {
  int value, freq;
} arr[101];
bool compare(a1 lhs, a1 rhs) { return lhs.freq > rhs.freq; }
int main() {
  int temp = 0, j, n, num = 0, m, i, a[101], ans = 0;
  scanf("%d %d", &n, &m);
  int b[n], c[n];
  memset(a, 0, sizeof(a));
  for (i = 0; i < n; i++) {
    scanf("%d", &temp);
    a[temp]++;
  }
  temp = 0;
  for (i = 1; i <= 100; i++) {
    if (a[i] != 0) {
      arr[num].freq = a[i];
      arr[num++].value = i;
    }
  }
  sort(arr, arr + num, compare);
  for (i = 0; i < num; i++) {
    j = 0;
    while (j < arr[i].freq) {
      b[temp++] = arr[i].value;
      j++;
    }
  }
  for (i = arr[0].freq; i < n; i++) {
    c[i - arr[0].freq] = b[i];
  }
  for (i = 0; i < arr[0].freq; i++) {
    c[n - arr[0].freq + i] = arr[0].value;
  }
  for (i = 0; i < n; i++) {
    if (b[i] != c[i]) ans++;
  }
  printf("%d\n", ans);
  for (i = 0; i < n; i++) {
    printf("%d %d\n", b[i], c[i]);
  }
  return 0;
}
