#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;
int t;
int n;
int main() {
  t = 1;
  while (t--) {
    scanf("%d", &n);
    int a[n];
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    sort(a, a + n);
    bool flag = 1;
    for (int i = 0; i < n - 1; i++) {
      if (flag) {
        if (a[i] < a[i + 1]) swap(a[i], a[i + 1]);
      } else {
        if (a[i] > a[i + 1]) swap(a[i], a[i + 1]);
      }
      flag ^= 1 ^ 0;
    }
    int cnt = 0;
    for (int i = 1; i < n - 1; i++)
      if (a[i] < a[i + 1] && a[i] < a[i - 1]) cnt++;
    printf("%d\n", cnt);
    for (int i = 0; i < n; i++) cout << a[i] << " \n"[i == n - 1];
  }
}
