#include <bits/stdc++.h>
using namespace std;
int n, m, a[5010], res;
pair<int, int> c[111];
vector<int> x, y;
bool cmp(pair<int, int> i, pair<int, int> j) { return i > j; }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    c[a[i]].first++;
    c[a[i]].second = a[i];
  }
  sort(c + 1, c + 101, cmp);
  for (int j = 0; j < c[1].first; j++) y.push_back(c[1].second);
  for (int i = 2; i <= n; i++) {
    if (c[i].second == 0) break;
    for (int j = 0; j < c[i].first; j++)
      x.push_back(c[i].second), y.push_back(c[i].second);
  }
  for (int j = 0; j < c[1].first; j++) x.push_back(c[1].second);
  for (int i = 0; i < x.size(); i++)
    if (x[i] != y[i]) res++;
  printf("%d\n", res);
  for (int i = 0; i < x.size(); i++) {
    printf("%d %d\n", x[i], y[i]);
  }
  return 0;
}
