#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int N = 1e5 + 9;
int ans[1009];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int x, m, c = 0;
  cin >> x >> m;
  pair<int, int> p[x];
  for (int i = 0; i < x; i++) {
    cin >> p[i].first;
    p[i].second = p[i].first;
  }
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < x; j++) {
      if (p[i].first != p[j].second && p[i].second != p[j].first) {
        swap(p[i].first, p[j].first);
        break;
      }
    }
  }
  for (int i = 0; i < x; i++) {
    if (p[i].first != p[i].second) c++;
  }
  cout << c << '\n';
  for (int i = 0; i < x; i++) {
    cout << p[i].first << " " << p[i].second << '\n';
  }
  return 0;
}
