#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  while (cin >> n >> m) {
    vector<int> colors(n);
    for (int i = 0; i < n; ++i) cin >> colors[i];
    sort(colors.begin(), colors.end());
    vector<int> match(colors);
    rotate(match.begin(), match.begin() + n / 2, match.end());
    int ans = 0;
    for (int i = 0; i < n; ++i)
      if (colors[i] != match[i]) ++ans;
    cout << ans << endl;
    for (int i = 0; i < n; ++i) cout << colors[i] << " " << match[i] << endl;
  }
  return 0;
}
