#include <bits/stdc++.h>
using namespace std;
int l[5005], r[5005];
int main() {
  int i, n, m, ans, half;
  while (scanf("%d%d", &n, &m) != EOF) {
    ans = 0;
    half = (n + 1) / 2;
    for (i = 0; i < n; i++) scanf("%d", &l[i]);
    sort(l, l + n);
    for (i = 0; i < n; i++) {
      r[i] = l[(i + half) % n];
      ans += l[i] != r[i];
    }
    printf("%d\n", ans);
    for (i = 0; i < n; i++) printf("%d %d\n", l[i], r[i]);
  }
  return 0;
}
