#include <bits/stdc++.h>
using namespace std;
const int maxn = 111111;
int n, m, i, an, a[maxn];
int f(int x) { return (x ? x : n); }
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; ++i) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  an = 0;
  for (i = 1; i <= n; ++i) an += (a[i] != a[f((i + (n >> 1)) % n)]);
  printf("%d\n", an);
  for (i = 1; i <= n; ++i) printf("%d %d\n", a[i], a[f((i + (n >> 1)) % n)]);
  return 0;
}
