#include <bits/stdc++.h>
using namespace std;
void fastio() {
  cin.tie(nullptr);
  cin.sync_with_stdio(false);
}
using LL = long long;
using LD = long double;
const LL MOD = 1e9 + 7;
const LL INF = LLONG_MAX;
const LL N = 2e5 + 1;
int main() {
  fastio();
  LL n;
  cin >> n;
  vector<LL> a(n);
  for (auto &e : a) {
    cin >> e;
  }
  vector<LL> ans(n, 0);
  sort(a.begin(), a.end(), greater<LL>());
  LL p = 0;
  for (LL i = 0; i < n; i += 2) {
    ans[i] = a[p++];
  }
  for (LL i = 0; i < n; ++i) {
    if (ans[i] == 0) {
      ans[i] = a[p++];
    }
  }
  cout << (n - 1) / 2 << "\n";
  for (auto &e : ans) {
    cout << e << " ";
  }
  cout << "\n";
}
