#include <bits/stdc++.h>
using namespace std;
int a[100002], t[10000];
int main() {
  int n;
  cin >> n;
  int MAX = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    t[a[i]]++;
    MAX = max(MAX, a[i]);
  }
  int ans = 0;
  for (int i = 0; i < MAX; i++)
    if (t[i] == 1)
      ans++;
    else if (t[i] > 1)
      ans += 2;
  ans++;
  cout << ans << endl;
  sort(a, a + n);
  n = unique(a, a + n) - a;
  for (int i = 0; i < n; i++) cout << a[i] << " ";
  for (int i = n - 2; i >= 0; i--)
    if (t[a[i]] > 1) cout << a[i] << " ";
  cout << endl;
  return 0;
}
