#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  vector<int> v;
  vector<int> v1;
  vector<int> v2;
  int mx = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] > mx) {
      v1.push_back(a[i]);
      mx = a[i];
    } else
      v.push_back(a[i]);
  }
  int mn = mx;
  for (int i = v.size() - 1; i >= 0; i--) {
    if (v[i] < mn) {
      v2.push_back(v[i]);
      mn = v[i];
    }
  }
  cout << v1.size() + v2.size() << endl;
  for (int i = 0; i < v1.size(); i++) cout << v1[i] << " ";
  for (int i = 0; i < v2.size(); i++) cout << v2[i] << " ";
}
