#include <bits/stdc++.h>
using namespace std;
int visit[5010];
int ans[100010];
int main() {
  int n, x;
  scanf("%d", &n);
  while (n--) {
    scanf("%d", &x);
    visit[x]++;
  }
  int len = 0;
  for (int i = 1; i <= 5000; i++)
    if (visit[i]) {
      ans[++len] = i;
      visit[i]--;
    }
  for (int i = ans[len] - 1; i >= 1; i--)
    if (visit[i]) {
      ans[++len] = i;
      visit[i]--;
    }
  cout << len << endl;
  for (int i = 1; i <= len; i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
