#include <bits/stdc++.h>
using namespace std;
int N, ar[100200], used[100200];
vector<int> v, v2;
void oku() {
  scanf(" %d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &ar[i]);
  }
  sort(ar + 1, ar + 1 + N);
  ar[N + 1] = INT_MIN;
  int j = N + 1, kac = 0;
  for (int i = 1; i < N; i++)
    if (ar[i] < ar[N] && ar[i] > ar[j]) {
      kac++;
      used[i] = 1;
      v.push_back(ar[i]);
      j = i;
    }
  j = N + 1;
  for (int i = 1; i <= N; i++)
    if (!used[i] && ar[i] < ar[N] && ar[i] > ar[j]) {
      kac++;
      v2.push_back(ar[i]);
      j = i;
    }
  printf("%d\n", kac + 1);
  for (int i = 0; i < v.size(); i++) printf("%d ", v[i]);
  if (N != 1 && v2.size())
    printf("%d ", ar[N]);
  else
    printf("%d", ar[N]);
  for (int i = v2.size() - 1; i >= 0; i--) printf("%d ", v2[i]);
  puts("");
}
int main() {
  oku();
  return 0;
}
