#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  long long int TC, i, j, k;
  TC = 1;
  while (TC--) {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    sort(a, a + n);
    int b[n];
    if (n <= 2) {
      cout << 0 << "\n";
      for (int i = 0; i < n; i++) {
        cout << a[i] << " ";
      }
      cout << "\n";
    } else if (n % 2 == 0) {
      cout << (n - 2) / 2 << "\n";
      j = 0;
      for (int i = 0; i < n; i++) {
        if (i % 2 == 1) {
          b[i] = a[j];
          j++;
        }
      }
      for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
          b[i] = a[j];
          j++;
        }
      }
      for (int i = 0; i < n; i++) {
        cout << b[i] << " ";
      }
      cout << "\n";
    } else {
      cout << (n - 1) / 2 << "\n";
      j = 0;
      for (int i = 0; i < n; i++) {
        if (i % 2 == 1) {
          b[i] = a[j];
          j++;
        }
      }
      for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
          b[i] = a[j];
          j++;
        }
      }
      for (int i = 0; i < n; i++) {
        cout << b[i] << " ";
      }
      cout << "\n";
    }
  }
  return 0;
}
