#include <bits/stdc++.h>
using namespace std;
const long long logN = 20;
const long long M = 1000000007;
const long long INF = 1e18;
int main() {
  int n;
  cin >> n;
  vector<int> A;
  int x;
  for (int j = 0; j < n; j++) {
    cin >> x;
    A.push_back(x);
  }
  sort(A.begin(), A.end());
  int count = 0;
  vector<int> ans;
  int t = (n - 3) / 2;
  n--;
  ans.push_back(A[n]);
  n--;
  for (int k = t; k >= 0; k--) {
    if (A[k] < A[n]) {
      count++;
      ans.push_back(A[k]);
      ans.push_back(A[n]);
      n--;
    } else {
      ans.push_back(A[k]);
    }
  }
  while (n > t) {
    ans.push_back(A[n]);
    n--;
  }
  cout << count << endl;
  for (int i = 0; i < A.size(); i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
