#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n), b;
  for (int i = 0; i < n; i++) cin >> v[i];
  int j = 0;
  sort(v.begin(), v.end());
  b.push_back(v[0]);
  v[0] = 0;
  for (int i = 1; i < n; i++) {
    if (b[j] != v[i]) {
      b.push_back(v[i]);
      j++;
      v[i] = 0;
    }
  }
  cout << endl;
  for (int i = v.size() - 1; i >= 0; i--) {
    if (b[j] != v[i] && v[i] != 0) {
      b.push_back(v[i]);
      j++;
    }
  }
  cout << b.size() << endl;
  for (int i : b) cout << i << " ";
  return 0;
}
