#include <bits/stdc++.h>
using namespace std;
const int oo = 100010;
int n, a[oo], m, x, y, b[oo], xxx;
vector<int> v, u;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (!b[a[i]]) v.push_back(a[i]);
    if (b[a[i]] == 1) u.push_back(a[i]);
    b[a[i]]++;
  }
  if (u.size()) {
    sort(v.begin(), v.end());
    sort(u.begin(), u.end());
    if (v[v.size() - 1] == u[u.size() - 1]) u.pop_back();
    cout << v.size() + u.size() << endl;
    for (int i = 0; i < v.size(); i++) cout << v[i] << ' ';
    for (int i = u.size() - 1; i >= 0; i--) cout << u[i] << ' ';
  } else {
    sort(v.begin(), v.end());
    cout << v.size() << endl;
    for (int i = 0; i < v.size(); i++) cout << v[i] << ' ';
  }
  return 0;
}
