#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e8;
const double EPS = 1e-9;
const long long MOD = (long long)(1e9 + 7);
const long long MAXV = (long long)(5e3 + 10);
const long long MAXE = (long long)(1e5 + 10);
int n, m;
int c[200];
vector<pair<int, int> > aux;
bool cmp(pair<int, int> a, pair<int, int> b) { return a.first > b.first; }
vector<int> L, R;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    c[a]++;
  }
  for (int i = 0; i <= 100; i++)
    if (c[i]) aux.push_back(pair<int, int>(c[i], i));
  sort(aux.begin(), aux.end(), cmp);
  int r = aux[0].first;
  for (int i = 0; i < aux.size(); i++)
    for (int j = 0; j < aux[i].first; j++) L.push_back(aux[i].second);
  R = L;
  rotate(R.begin(), R.begin() + r, R.end());
  int cnt = 0;
  for (int i = 0; i < L.size(); i++)
    if (L[i] != R[i]) cnt++;
  cout << cnt << "\n";
  for (int i = 0; i < L.size(); i++) cout << L[i] << " " << R[i] << "\n";
  return 0;
}
