#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool elem(set<T> st, T val) {
  return (st.find(val) != st.end());
}
template <typename T>
void printv(vector<T> vt) {
  if (vt.size() == 0) return;
  for (int i = 0; i < (int)vt.size() - 1; ++i) cout << vt[i] << " ";
  cout << vt[vt.size() - 1] << endl;
}
int cl[101];
vector<pair<int, int> > clv;
int main(void) {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < (int)n; ++i) {
    int d;
    cin >> d;
    cl[d]++;
  }
  vector<pair<int, int> > ret;
  int retc = 0;
  for (int i = 1; i <= 100; ++i) clv.push_back(make_pair(cl[i], i));
  while (n > 3) {
    sort(clv.begin(), clv.end(), greater<pair<int, int> >());
    if (clv[0].first > 0 && clv[1].first > 0) {
      clv[0].first--;
      clv[1].first--;
      ret.push_back(make_pair(clv[0].second, clv[1].second));
      ret.push_back(make_pair(clv[1].second, clv[0].second));
      n -= 2;
      retc += 2;
    } else
      break;
  }
  sort(clv.begin(), clv.end(), greater<pair<int, int> >());
  if (clv[1].first != 0) {
    if (n == 3) {
      if (clv[0].first == 1 && clv[1].first == 1 && clv[2].first == 1) {
        ret.push_back(make_pair(clv[0].second, clv[1].second));
        ret.push_back(make_pair(clv[1].second, clv[2].second));
        ret.push_back(make_pair(clv[2].second, clv[0].second));
        n -= 3;
        retc += 3;
      } else {
        if (clv[0].first == 2) {
          ret.push_back(make_pair(clv[0].second, clv[1].second));
          ret.push_back(make_pair(clv[1].second, clv[0].second));
          n -= 2;
          retc += 2;
        }
      }
    } else {
      ret.push_back(make_pair(clv[0].second, clv[1].second));
      ret.push_back(make_pair(clv[1].second, clv[0].second));
      n -= 2;
      retc += 2;
    }
  } else {
    for (int i = 0; i < (int)n; ++i)
      ret.push_back(make_pair(clv[0].second, clv[0].second));
  }
  cout << retc << endl;
  for (int i = 0; i < (int)ret.size(); ++i) {
    cout << ret[i].first << " " << ret[i].second << endl;
  }
  return 0;
}
