#include <bits/stdc++.h>
using namespace std;
int n;
int arr[100001];
int main() {
  while (scanf("%d", &n) == 1) {
    map<int, int> m;
    for (int i = 0; i < n; i++) {
      scanf("%d", &arr[i]);
      map<int, int>::iterator it = m.find(arr[i]);
      if (it != m.end()) {
        m[arr[i]]++;
      } else {
        m[arr[i]] = 1;
      }
    }
    int size = 0;
    vector<int> l, r;
    int a = 0, b = 0;
    for (int i = 1; i <= 5000; i++) {
      if (m.find(i) != m.end()) {
        if (m[i] == 1) {
          size++;
          l.push_back(i);
          a++;
        } else {
          size += 2;
          l.push_back(i);
          r.push_back(i);
          a++;
          b++;
        }
      }
    }
    if (a > 0 && b > 0 && l[a - 1] == r[b - 1]) b--;
    printf("%d\n", a + b);
    for (int i = 0; i < a; i++) {
      if (i != 0) printf(" ");
      printf("%d", l[i]);
    }
    for (int i = b - 1; i >= 0; i--) printf(" %d", r[i]);
    printf("\n");
  }
}
