#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < (n); i++) cin >> a[i];
  sort(a, a + n);
  int tk[n];
  memset(tk, 0, sizeof(tk));
  int pv = -1;
  vector<int> ans;
  for (int i = 0; i < (n); i++) {
    if (a[i] != pv) {
      tk[i] = 1;
      pv = a[i];
      ans.push_back(a[i]);
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] < pv && !tk[i]) {
      ans.push_back(a[i]);
      pv = a[i];
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < (ans.size()); i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
