#include <bits/stdc++.h>
using namespace std;
int n, m, vis[190], ans;
vector<int> v, vv;
int main() {
  cin >> n >> m;
  v.resize(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  vv = v;
  for (int i = 0; i < n; i++) {
    if (v[i] == vv[i]) {
      for (int h = i + 1; h < n; h++)
        if (vv[i] != vv[h] && v[i] != v[h]) {
          swap(vv[i], vv[h]);
          break;
        }
    }
  }
  for (int i = 0; i < n; i++) {
    if (v[i] == vv[i]) {
      for (int h = 0; h < i; h++)
        if (v[i] != vv[h] && vv[i] != v[h]) swap(vv[h], vv[i]);
      if (v[i] == vv[i]) {
        for (int h = i + 1; h < n; h++)
          if (v[i] != vv[h] && vv[i] != v[h]) swap(vv[h], vv[i]);
      }
    }
  }
  for (int i = 0; i < n; i++)
    if (vv[i] != v[i]) ans++;
  cout << ans << "\n";
  for (int i = 0; i < n; i++) cout << v[i] << ' ' << vv[i] << endl;
  return 0;
}
