#include <bits/stdc++.h>
using namespace std;
int get_int() {
  int x = 0;
  char c;
  for (c = getchar(); c < '0' || c > '9'; c = getchar())
    ;
  for (; c >= '0' && c <= '9'; c = getchar()) {
    x *= 10;
    x += c - 48;
  }
  return x;
}
int c[5050], a[10050];
int f[105];
int l[5050], r[5050];
int b[10050];
struct node {
  int c, t;
} q[105];
bool cmp(node x, node y) { return x.t > y.t; }
int main() {
  int n = get_int(), m = get_int();
  for (int i = 1; i <= n; i++) f[get_int()] += 2;
  int size = 0;
  for (int i = 1; i <= 100; ++i)
    if (f[i]) {
      size++;
      q[size].c = i;
      q[size].t = f[i];
    }
  sort(q + 1, q + size + 1, cmp);
  int t = 0;
  for (int i = 1; i <= size; i++) {
    for (int j = 1; j <= q[i].t; j++) {
      if (j <= q[i].t / 2) {
        t++;
        if (t <= n) {
          l[t] = q[i].c;
          continue;
        }
        for (int k = 1; k <= n; k++)
          if (!l[k]) {
            l[k] = q[i].c;
            break;
          }
      } else {
        t++;
        if (t <= n) {
          r[t] = q[i].c;
          continue;
        }
        for (int k = 1; k <= n; k++)
          if (!r[k]) {
            r[k] = q[i].c;
            break;
          }
      }
    }
  }
  int ans = n;
  for (int i = 1; i <= n; i++)
    if (l[i] == r[i]) ans--;
  printf("%d\n", ans);
  for (int i = 1; i <= n; i++) printf("%d %d\n", l[i], r[i]);
}
