#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int k = n / 2, y = 0, count = 0;
  for (int j = 0; j < n / 2; j++) {
    if (a[j] < a[k] && a[j] < a[k + 1] && k < n - 1) {
      count++;
    }
    k++;
  }
  cout << count << endl;
  k = n / 2;
  for (; k < n; k++) {
    cout << a[k] << " ";
    if (y < (n / 2)) cout << a[y] << " ";
    y++;
  }
  return 0;
}
