#include <bits/stdc++.h>
using namespace std;
ifstream fin("w.in");
ofstream fout("w.out");
const int DIM = 100005;
int n, v[DIM], ans;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> v[i];
  sort(v + 1, v + 1 + n);
  for (int i = n - 1; i >= 2; i -= 2) swap(v[i], v[i - 1]);
  for (int i = 2; i < n; i++) {
    if (v[i] < v[i - 1] && v[i] < v[i + 1]) ans++;
  }
  cout << ans << '\n';
  for (int i = 1; i <= n; i++) cout << v[i] << " ";
}
