#include <bits/stdc++.h>
using namespace std;
set<int> st;
set<int> en;
vector<int> out;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    if (st.find(t) == st.end())
      st.insert(t);
    else if (en.find(t) == en.end())
      en.insert(t);
  }
  int ma = 0;
  for (set<int>::iterator it = st.begin(); it != st.end(); it++) {
    out.push_back(*it);
    ma = max(ma, (*it));
  }
  for (set<int>::reverse_iterator it = en.rbegin(); it != en.rend(); it++)
    if ((*it) != ma) out.push_back(*it);
  cout << out.size() << endl;
  for (int i = 0; i < out.size(); i++) cout << out[i] << " ";
}
