#include <bits/stdc++.h>
const long long mod = 1000000007;
const double PI = 3.14159265358979323846;
using namespace std;
bool comp(long long a, long long b) { return a > b; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long m;
  cin >> m;
  long long* a = new long long[5001];
  for (long long i = 0; i <= 5000; i++) a[i] = 0;
  for (long long i = 0; i < m; i++) {
    long long val;
    cin >> val;
    a[val]++;
  }
  vector<long long> v;
  for (long long i = 5000; i >= 1; i--) {
    if (a[i] > 0) {
      v.push_back(i);
      a[i]--;
    }
  }
  vector<long long> v2;
  for (long long i = 1; i <= 5000; i++) {
    if (a[i] > 0 && i != v[0]) {
      v2.push_back(i);
      a[i]--;
    }
  }
  cout << (v.size() + v2.size()) << endl;
  for (long long i = 0; i < v2.size(); i++) cout << v2[i] << " ";
  for (long long i = 0; i < v.size(); i++) cout << v[i] << " ";
}
