#include <bits/stdc++.h>
using namespace std;
vector<int> v[5010];
int n, num[5010];
int m;
int L[5010], R[5010];
bool col[5010];
void match(int n);
bool dfs(int s);
int main() {
  int i, j, k, l, test, t = 1;
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", &num[i]);
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      if (num[i] == num[j]) continue;
      v[i].push_back(j);
    }
  }
  match(n);
  return 0;
}
void match(int n) {
  memset(L, -1, sizeof(L));
  memset(R, -1, sizeof(R));
  int i, j, k, l;
  int done;
  do {
    done = 1;
    memset(col, 0, sizeof(col));
    for (i = 1; i <= n; i++) {
      if (L[i] == -1 && dfs(i)) done = 0;
    }
  } while (!done);
  k = 0;
  for (i = 1; i <= n; i++) {
    if (L[i] != -1) k++;
  }
  printf("%d\n", k);
  for (i = 1; i <= n; i++) {
    if (L[i] == -1) L[i] = i;
    printf("%d %d\n", num[i], num[L[i]]);
  }
}
bool dfs(int s) {
  if (col[s]) return 0;
  col[s] = 1;
  int i, j, k, l;
  for (j = 0; j < v[s].size(); j++) {
    i = v[s][j];
    if (R[i] == -1) {
      R[i] = s;
      L[s] = i;
      R[s] = i;
      L[i] = s;
      col[i] = 1;
      return true;
    }
    if (dfs(R[i])) {
      R[i] = s;
      L[s] = i;
      return true;
    }
  }
  return false;
}
