#include <bits/stdc++.h>
using namespace std;
void solve(long long cno) {
  long long n, i, j, k;
  cin >> n;
  long long arr[n];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  if (n < 3) {
    cout << 0 << endl;
    for (auto x : arr) {
      cout << x << " ";
    }
    return;
  }
  sort(arr, arr + n);
  long long ans[n];
  long long ptr = 0;
  for (i = 1; i < n; i += 2) {
    ans[i] = arr[ptr++];
  }
  for (i = 0; i < n; i += 2) {
    ans[i] = arr[ptr++];
  }
  cout << (n - 1) / 2 << endl;
  for (auto x : ans) {
    cout << x << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long TESTS = 1;
  long long i = 1;
  while (TESTS--) {
    solve(i);
    i++;
  }
  return 0;
}
