#include <bits/stdc++.h>
int a[10001];
int main() {
  int i, j, k;
  int n, m;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  std::sort(a, a + n);
  for (i = 0; i < n; i++) {
    a[n + i] = a[i];
  }
  int max = 0, p = 0;
  for (i = 0; i < n; i++) {
    for (j = k = 0; j < n; j++) {
      if (a[j] != a[i + j]) {
        k++;
      }
    }
    if (max < k) {
      max = k;
      p = i;
    }
  }
  printf("%d\n", max);
  for (i = 0; i < n; i++) {
    printf("%d %d\n", a[i], a[p + i]);
  }
}
