#include <bits/stdc++.h>
using namespace std;
ifstream fin("Sisend.txt");
int n, c;
bool b[100005];
vector<int> v, v1;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cerr.tie(0);
  cin >> n;
  for (int(i) = (0); ((i)) < ((n)); ((i))++) {
    cin >> c;
    v.emplace_back(c);
  }
  sort(v.rbegin(), v.rend());
  int l = 1, r = v.size() / 2 + 1;
  int vas = 0;
  v1.emplace_back(v[0]);
  while (r < v.size()) {
    while (r < v.size() and v[r] == v[l]) r++;
    v1.emplace_back(v[r]), v1.emplace_back(v[l]);
    b[r] = 1;
    vas++;
    l++;
    r++;
  }
  while (l < v.size()) {
    if (!b[l]) {
      v1.emplace_back(v[l]);
    }
    l++;
  }
  cout << vas << endl;
  for (int i : v1) cout << i << " ";
}
