#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> C(N);
  for (int& c : C) {
    cin >> c;
  }
  sort(C.begin(), C.end());
  int best_diff = 0;
  int best_shift = 0;
  for (int shift = 1; shift < N; ++shift) {
    int diff = 0;
    for (int i = 0; i < N; ++i) {
      if (C[i] != C[(i + shift) % N]) {
        ++diff;
      }
    }
    if (diff > best_diff) {
      best_diff = diff;
      best_shift = shift;
    }
  }
  cout << best_diff << '\n';
  for (int i = 0; i < N; ++i) {
    cout << C[i] << ' ' << C[(i + best_shift) % N] << '\n';
  }
  return 0;
}
