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