#include <bits/stdc++.h>
using namespace std;
int src = 0;
int snk = 201;
int n, m;
int a[5000], cnt[101];
int c[205][205], f[205][205], r[205][205];
vector<int> path;
int visited[205];
int dfs(int u) {
  visited[u] = 1;
  path.push_back(u);
  if (u == snk) {
    return 1;
  }
  for (int i = 1; i <= snk; ++i) {
    if (!visited[i] && r[u][i] > 0) {
      if (dfs(i)) {
        return 1;
      }
    }
  }
  path.pop_back();
  return 0;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    cnt[a[i]]++;
  }
  for (int i = 1; i <= 100; ++i) {
    c[src][i] = cnt[i];
  }
  for (int i = 1; i <= 100; ++i) {
    for (int j = 1; j <= 100; ++j) {
      if (i != j) {
        c[i][j + 100] = cnt[i];
      }
    }
    c[i + 100][snk] = cnt[i];
  }
  for (int i = src; i <= snk; ++i) {
    for (int j = src; j <= snk; ++j) {
      r[i][j] = c[i][j];
    }
  }
  int ans = 0;
  while (dfs(src)) {
    int len = path.size();
    int minv = 99999999;
    for (int i = 0; i < len - 1; ++i) {
      minv = min(minv, r[path[i]][path[i + 1]]);
    }
    ans += minv;
    for (int i = 0; i < len - 1; ++i) {
      int u = path[i], v = path[i + 1];
      f[u][v] += minv;
      r[u][v] = c[u][v] - f[u][v];
      f[v][u] = -f[u][v];
      r[v][u] = c[v][u] - f[v][u];
    }
    path.clear();
    fill(visited, visited + snk + 1, 0);
  }
  printf("%d\n", ans);
  for (int i = 1; i <= 100; ++i) {
    if (cnt[i] == 0) {
      continue;
    }
    int sum = 0;
    for (int j = 101; j <= 200; ++j) {
      sum += f[i][j];
      for (int k = 0; k < f[i][j]; ++k) {
        printf("%d %d\n", i, j - 100);
      }
    }
    for (int j = 0; j < cnt[i] - sum; ++j) {
      printf("%d %d\n", i, i);
    }
  }
  return 0;
}
