#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
int card[100001], result[100001];
bool used[100001];
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) {
      scanf("%d", &card[i]);
    }
    sort(card, card + n);
    memset(used, false, sizeof(used));
    int lp = 0, pre = 1e9;
    for (int i = 0; i < n; i++) {
      if (card[i] != pre) {
        result[lp++] = card[i];
        used[i] = true;
      }
      pre = card[i];
    }
    pre = card[n - 1];
    for (int i = n - 1; i >= 0; i--) {
      if (card[i] != pre && used[i] == false) {
        result[lp++] = card[i];
      }
      pre = card[i];
    }
    printf("%d\n", lp);
    for (int i = 0; i < lp - 1; i++) {
      printf("%d ", result[i]);
    }
    printf("%d\n", result[lp - 1]);
  }
  return 0;
}
