#include <bits/stdc++.h>
using namespace std;
int cnt[5010], arr1[100000 + 10], arr2[100000 + 10];
int main() {
  int n, tmp;
  while (cin >> n) {
    long long s1, s2;
    s1 = s2 = 0;
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < n; i++) {
      scanf("%d", &tmp);
      if (cnt[tmp] == 0) {
        arr1[s1++] = tmp;
      } else if (cnt[tmp] == 1) {
        arr2[s2++] = tmp;
      }
      cnt[tmp]++;
    }
    sort(arr1, arr1 + s1);
    sort(arr2, arr2 + s2);
    if (s1 > 0 && s2 > 0) {
      if (arr1[s1 - 1] == arr2[s2 - 1]) {
        s1--;
      }
    }
    printf("%d\n", s1 + s2);
    for (int i = 0; i < s1; i++) {
      if (i == 0)
        cout << arr1[i];
      else
        cout << " " << arr1[i];
    }
    for (int i = s2 - 1; i >= 0; i--) {
      cout << " " << arr2[i];
    }
    cout << endl;
  }
  return 0;
}
