#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10000 + 10;
struct P {
  int n, l, r;
} n_res[MAXN];
int b[110];
int main() {
  int n, m, t;
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(b, 0, sizeof(b));
    for (int i = 0; i < n; i++) {
      scanf("%d", &t);
      b[t]++;
    }
    int i = 1, j = 100;
    int res = 0, k = 0;
    while (1) {
      while (i < j && b[i] == 0) i++;
      while (j > i && b[j] == 0) j--;
      if (i == j) break;
      int t = min(b[i], b[j]);
      res += t * 2;
      n_res[k].n = t, n_res[k].l = i, n_res[k].r = j;
      k++;
      n_res[k].n = t, n_res[k].l = j, n_res[k].r = i;
      k++;
      b[i] -= t, b[j] -= t;
    }
    if (b[j]) {
      for (int i = 0; i < k; i++) {
        if (n_res[i].l != j && n_res[i].r != j) {
          int t = min(n_res[i].n, b[j]);
          res += t;
          n_res[k].l = j, n_res[k].r = n_res[i].r;
          n_res[k].n = t;
          k++;
          if (n_res[i].n - t) {
            n_res[k].l = n_res[i].l, n_res[k].r = n_res[i].r,
            n_res[k].n = n_res[i].n - t;
            k++;
          }
          n_res[i].r = j, n_res[i].n = t;
          b[j] -= t;
          if (b[j] == 0) break;
        }
      }
    }
    printf("%d\n", res);
    for (int i = 0; i < k; i++) {
      for (int j = 0; j < n_res[i].n; j++)
        printf("%d %d\n", n_res[i].l, n_res[i].r);
    }
    for (int i = 1; i <= 100; i++) {
      if (b[i]) {
        for (int j = 0; j < b[i]; j++) printf("%d %d\n", i, i);
      }
    }
  }
  return 0;
}
