#include <bits/stdc++.h>
using namespace std;
template <class T>
typename T::value_type arr_sum(const T& v, int n) {
  typename T::value_type sum = 0;
  for (int i = 0; i < n; ++i) sum += v[i];
  return sum;
}
struct Sync_stdio {
  Sync_stdio() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
  }
} _sync_stdio;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> left;
  vector<int> right(n);
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    left.push_back(t);
  }
  sort(left.begin(), left.end());
  for (int i = 0, j = n / 2; i < n; ++i, j = (j + 1) % n) {
    right[i] = left[j];
  }
  int res = 0;
  for (int i = 0; i < n; ++i) {
    if (left[i] == right[i]) {
      ++res;
    }
  }
  cout << n - res << "\n";
  for (int i = 0; i < n; ++i) {
    cout << left[i] << " " << right[i] << "\n";
  }
}
