#include <bits/stdc++.h>
using namespace std;
int res_l[6100], res_r[6100];
int main() {
  int i, j, n, m, ans = 0;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) scanf("%d", &res_l[i]);
  sort(res_l, res_l + n);
  for (i = 0; i < n; i++) {
    res_r[i] = res_l[(i + n / 2) % n];
    if (res_r[i] != res_l[i]) ans++;
  }
  printf("%d\n", ans);
  for (i = 0; i < n; i++) printf("%d %d\n", res_l[i], res_r[i]);
  return 0;
}
