#include <bits/stdc++.h>
const int INF = 1e9 + 999, MOD = 1e9 + 7, MAXN = 200000;
const long double EPS = 0.000001;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, m, a[10000];
  vector<pair<int, int> > ans;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ans.push_back(make_pair(a[i], a[i]));
  }
  for (int i = 0; i < n; i++) {
    if (ans[i].first == ans[i].second) {
      for (int j = 0; j < n; j++) {
        if (i != j) {
          if ((ans[j].first != ans[i].second) &&
              (ans[i].first != ans[j].second)) {
            swap(ans[j].first, ans[i].first);
          } else if (ans[j].second != ans[i].first &&
                     ans[i].second != ans[j].first) {
            swap(ans[j].second, ans[i].second);
          }
        }
      }
    }
  }
  int kol = 0;
  for (int i = 0; i < n; i++) {
    if (ans[i].first != ans[i].second) kol++;
  }
  cout << kol << "\n";
  for (int i = 0; i < n; i++) {
    cout << ans[i].first << " " << ans[i].second << "\n";
  }
  return 0;
}
