#include <bits/stdc++.h>
using namespace std;
int n, m, t = 1, s, a[20010], l[20010], r[20010];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[t]);
    a[t + 1] = a[t];
    t += 2;
  }
  sort(a, a + 2 * n + 1);
  for (int i = 1; i <= n; i++) {
    if (a[i] != a[i + n]) {
      s++;
    }
    l[i] = a[i];
    r[i] = a[i + n];
  }
  cout << s << endl;
  for (int i = 1; i <= n; i++) {
    if (i & 1) {
      cout << l[i] << ' ' << r[i] << endl;
    } else {
      cout << r[i] << ' ' << l[i] << endl;
    }
  }
  return 0;
}
