#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, b, a;
  set<int> l, r;
  map<int, int> cards;
  map<int, int>::iterator it;
  set<int>::iterator sit;
  set<int>::reverse_iterator rit;
  bool flag;
  cin >> m;
  while (m--) {
    cin >> b;
    if (cards[b] < 2) cards[b]++;
  }
  it = cards.begin();
  while (it != cards.end()) {
    a = it->first;
    b = it->second;
    it++;
    if (it == cards.end()) {
      l.insert(a);
    } else {
      if (b == 2) {
        l.insert(a);
        r.insert(a);
      } else {
        l.insert(a);
      }
    }
  }
  flag = false;
  cout << r.size() + l.size() << "\n";
  if (r.size() == 0) {
    rit = l.rbegin();
    while (rit != l.rend()) {
      if (flag)
        cout << " ";
      else
        flag = true;
      cout << *rit;
      rit++;
    }
  } else {
    sit = l.begin();
    while (sit != l.end()) {
      if (flag)
        cout << " ";
      else
        flag = true;
      cout << *sit;
      sit++;
    }
    rit = r.rbegin();
    while (rit != r.rend()) {
      if (flag)
        cout << " ";
      else
        flag = true;
      cout << *rit;
      rit++;
    }
  }
  cout << "\n";
  return 0;
}
