#include <bits/stdc++.h>
using namespace std;
int n, t;
int v[5050];
vector<pair<int, int> > ans;
map<int, int> freq;
int main() {
  scanf("%d%d", &n, &t);
  int maior = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i]);
    freq[v[i]]++;
    if (freq[v[i]] > maior) maior = freq[v[i]];
  }
  sort(v, v + n);
  int cont = 0;
  for (int i = 0; i < n; i++) {
    ans.push_back(make_pair(v[i], v[(i + maior) % n]));
    if (v[i] != v[(i + maior) % n]) cont++;
  }
  printf("%d\n", cont);
  for (int i = 0; i < ans.size(); i++)
    printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
