#include <bits/stdc++.h>
using namespace std;
const int size1 = 1e6 + 7;
const int size2 = 1e4;
const long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long T;
  T = 1;
  while (T--) {
    long long n;
    cin >> n;
    cout << (n - 1) / 2 << endl;
    vector<long long> vi;
    for (long long i = 0; i < n; i++) {
      long long x;
      cin >> x;
      vi.push_back(x);
    }
    sort(vi.begin(), vi.end());
    long long ans[n + 1];
    long long k = 0;
    for (long long i = 1; i < n; i += 2) {
      ans[i] = vi[k++];
    }
    for (long long i = 0; i < n; i += 2) {
      ans[i] = vi[k++];
    }
    for (long long i = 0; i < n; i++) cout << ans[i] << " ";
    cout << endl;
  }
}
