#include <bits/stdc++.h>
const int M = 1e9 + 7;
using namespace std;
int main() {
  long long int n;
  cin >> n;
  multiset<long long int> s;
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    s.insert(x);
  }
  long long int count = 0;
  long long int a[n], b[n];
  auto it = s.begin();
  for (long long int i = 1; i < n - 1; i += 2) {
    a[i] = *it;
    b[i] = 1;
    count++;
    long long int y = *it;
    it++;
    s.erase(s.find(y));
  }
  auto k = s.begin();
  for (long long int i = 0; i < n; i++) {
    if (b[i] != 1) {
      a[i] = *k;
      k++;
    }
  }
  cout << count << "\n";
  for (auto i : a) {
    cout << i << " ";
  }
  cout << "\n";
  return 0;
}
