#include <bits/stdc++.h>
using namespace std;
using pii = pair<long long, long long>;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  set<long long> s;
  for (long long i = 1; i <= n; i++) {
    long long a;
    cin >> a;
    s.insert(a);
  }
  long long A[100100];
  for (long long i = 1; i <= n; i++) {
    if (i & 1) {
      auto it = prev(s.end());
      A[i] = *it;
      s.erase(it);
    } else {
      auto it = s.begin();
      A[i] = *it;
      s.erase(it);
    }
  }
  long long res = 0;
  for (long long i = 2; i < n; i++) {
    if (A[i - 1] > A[i] && A[i] < A[i + 1]) res++;
  }
  cout << res << '\n';
  for (long long i = 1; i <= n; i++) cout << A[i] << ' ';
  return 0;
}
