#include <bits/stdc++.h>
using namespace std;
const int NUMMITTEMS = 100;
int main() {
  int n, a, m;
  cin >> n >> m;
  vector<int> c(NUMMITTEMS);
  for (int i = 0; i < n; ++i) {
    cin >> a;
    c[a - 1]++;
  }
  vector<pair<int, int> > mittens;
  for (int i = 0; i < NUMMITTEMS; ++i) {
    mittens.push_back(make_pair(c[i], i));
  }
  sort(mittens.begin(), mittens.end());
  reverse(mittens.begin(), mittens.end());
  int k = n;
  if (mittens[0].first > (n / 2)) {
    k = 2 * (n - mittens[0].first);
  }
  cout << k << endl;
  vector<pair<int, int> > mittensL, mittensR;
  mittensL = mittens;
  mittensR = mittens;
  int pos1 = 0, pos2 = 1;
  for (int i = 0; i < n; ++i) {
    while (mittensL[pos1].first == 0) pos1++;
    while (mittensR[pos2].first == 0) pos2 = (pos2 + 1) % NUMMITTEMS;
    cout << mittens[pos1].second + 1 << ' ' << mittens[pos2].second + 1 << '\n';
    mittensL[pos1].first--;
    mittensR[pos2].first--;
  }
  return 0;
}
