#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%i%i", &n, &m);
  int arr[n];
  int cnt[111] = {0};
  for (int i = 0; i < n; i++) {
    scanf("%i", &arr[i]);
    cnt[arr[i]]++;
  }
  int Max = 0;
  for (int i = 0; i < 111; i++) Max = max(Max, cnt[i]);
  printf("%i\n", min((n - Max) * 2, n));
  sort(arr, arr + n);
  for (int i = 0; i < n; i++) printf("%i %i\n", arr[i], arr[(i + Max) % n]);
}
