#include <bits/stdc++.h>
using namespace std;
inline int mx(int x, int y) { return x > y ? x : y; }
int main() {
  int n;
  scanf("%d", &n);
  vector<int> arr(n + 2), f(5005);
  int a = 0, count = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &arr[i]);
    a = max(a, arr[i]);
    if (!f[arr[i]]) count++;
    f[arr[i]]++;
  }
  if (count == n) {
    printf("%d\n", n);
    for (int i = count; i > 1; i--) printf("%d ", i);
    printf("1\n");
  } else {
    int ans = 0;
    for (int i = 1; i <= a; i++)
      if (f[i]) {
        f[i] -= 1;
        arr[++ans] = i;
      }
    for (int i = a - 1; i >= 1; i--)
      if (f[i]) arr[++ans] = i;
    printf("%d\n", ans);
    for (int i = 1; i < ans; i++) printf("%d ", arr[i]);
    printf("%d\n", arr[ans]);
  }
  return 0;
  return 0;
}
