#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n], m = -1;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    m = max(a[i], m);
    mp[a[i]]++;
  }
  vector<int> v;
  vector<int> v2;
  for (int i = 1; i < m; i++) {
    if (mp[i]) {
      v.push_back(i);
      if (mp[i] > 1) {
        v2.push_back(i);
      }
    }
  }
  long long int x = v.size();
  long long int y = v2.size();
  cout << x + y + 1 << endl;
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << m << " ";
  for (int i = v2.size() - 1; i >= 0; i--) {
    cout << v2[i] << " ";
  }
  return 0;
}
