#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, j, k, m, n, t;
  cin >> n;
  long long int ar[n];
  for (i = 0; i < n; i++) cin >> ar[i];
  sort(ar, ar + n);
  long long int l = 0, r = n - 1;
  long long int p = 1;
  vector<long long int> v;
  while (l <= r) {
    if (p == 1) {
      v.push_back(ar[r--]);
    } else
      v.push_back(ar[l++]);
    p *= -1;
  }
  long long int ctr = 0;
  for (i = 1; i < n - 1; i++) {
    if (v[i] < v[i - 1] and v[i] < v[i + 1]) ctr++;
  }
  cout << ctr << endl;
  for (auto x : v) cout << x << ' ';
}
