#include <bits/stdc++.h>
using namespace ::std;
int A[100005], L[100005], R[100005];
int l1 = 0, l2 = 0;
int x, y;
int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);
  sort(A, A + n);
  L[l1++] = A[0];
  x = 0;
  if (n > 1) {
    R[l2++] = A[1];
    y = 1;
  }
  bool f = false;
  for (int i = 2; i < n; i++) {
    if (!f) {
      if (A[x] != A[i]) {
        L[l1++] = A[i];
        x = i;
        f = true;
      }
    } else {
      if (A[y] != A[i]) {
        R[l2++] = A[i];
        y = i;
        f = false;
      }
    }
  }
  if (R[l2 - 1] != L[l1 - 1]) {
    printf("%d\n", l1 + l2);
    for (int i = 0; i < l1; i++) printf("%d ", L[i]);
    for (int i = l2 - 1; i >= 0; i--) printf("%d ", R[i]);
    printf("\n");
  } else {
    printf("%d\n", l1 + l2 - 1);
    for (int i = 0; i < l1; i++) printf("%d ", L[i]);
    for (int i = l2 - 2; i >= 0; i--) printf("%d ", R[i]);
    printf("\n");
  }
  return 0;
}
