#include <bits/stdc++.h>
using namespace std;
int n, m, a[5500];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int cnt = 0;
  for (int i = 0; i < n; i++) cnt += (a[i] != a[(i + (n / 2)) % n]);
  cout << cnt << endl;
  for (int i = 0; i < n; i++)
    cout << a[i] << " " << a[(i + (n / 2)) % n] << endl;
  return 0;
}
