#include <bits/stdc++.h>
using namespace std;
int a[100005], b[100005], dem[100005];
int n, d;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  sort(b + 1, b + 1 + n);
  d = 0;
  for (int i = 1; i <= n; i++)
    if (b[i] != b[i - 1]) {
      d++;
      a[d] = b[i];
      dem[d] = 1;
    } else
      dem[d] = 2;
  int kq = 0;
  for (int i = 1; i <= d; i++) kq += dem[i];
  if (dem[d] == 2) kq--;
  printf("%d\n", kq);
  for (int i = 1; i <= d; i++) printf("%d ", a[i]);
  for (int i = d - 1; i > 0; i--)
    if (dem[i] == 2) printf("%d ", a[i]);
  return 0;
}
