#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> cnt(5005), v(n), v1, v2;
  for (auto &it : v) cin >> it;
  sort(v.begin(), v.end());
  for (auto it : v) {
    if (cnt[it] == 0) {
      v1.push_back(it);
      cnt[it]++;
    } else if (cnt[it] == 1) {
      v2.push_back(it);
      cnt[it]++;
    }
  }
  reverse(v2.begin(), v2.end());
  if (v1.size() && v2.size()) {
    if (v1.back() == v2.front()) v1.pop_back();
  }
  v1.insert(v1.end(), v2.begin(), v2.end());
  cout << v1.size() << "\n";
  for (auto it : v1) cout << it << " ";
}
