#include <bits/stdc++.h>
using namespace std;
int a[100001], b[50000], c[50000];
int main() {
  int m;
  cin >> m;
  int ans = m;
  for (int i = 0; i < m; i++) cin >> a[i];
  sort(a, a + m);
  int top = a[m - 1];
  int bi = 0, ci = 0;
  for (int i = 0; i < m;) {
    int j = i + 1;
    bool twice = false;
    b[bi] = a[i];
    bi++;
    while (a[j] == a[i]) {
      if (!twice && a[i] != top) {
        c[ci] = a[i];
        twice = true;
        ci++;
      } else
        ans--;
      j++;
    }
    i = j;
  }
  cout << ans << endl;
  for (int i = 0; i < bi; i++) cout << b[i] << " ";
  for (int i = ci - 1; i >= 0; i--) cout << c[i] << " ";
  return 0;
}
