#include <bits/stdc++.h>
using namespace std;
int main() {
  int m;
  cin >> m;
  vector<int> a;
  for (int i = 0; i < m; i++) {
    int temp;
    cin >> temp;
    a.push_back(temp);
  }
  sort(a.begin(), a.end());
  vector<int> s;
  int temp = m;
  for (int i = 0; i < temp; i++) {
    if (a[i] != a[i + 1]) {
      s.push_back(a[i]);
      a.erase(a.begin() + i);
      temp = a.size();
      i = i - 1;
    }
  }
  if (a.size() != 0 && a.back() != s.back()) s.push_back(a[a.size() - 1]);
  for (int i = a.size() - 1; i >= 0; i--) {
    if (a[i] < s.back()) s.push_back(a[i]);
  }
  cout << s.size() << endl;
  for (int i = 0; i < s.size() - 1; i++) cout << s[i] << " ";
  cout << s[s.size() - 1] << endl;
}
