#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int test, i, j, count, flag = 0, n, o1 = 0, o2 = 0, b1, x, y, m, l,
                                   z, max1, x1, y1, x2, y2, z1, k, sum, f, r,
                                   ans1, min1;
  cin >> n;
  long long int a[n];
  if (n == 1) {
    cin >> x;
    cout << "1 \n" << x;
    return 0;
  }
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  vector<long long int> a1;
  vector<long long int> a2;
  flag = 0;
  for (i = 0; i < n; i++) {
    if (a1.size() == 0) {
      a1.push_back(a[i]);
    } else {
      if (a2.size() == 0) {
        a2.push_back(a[i]);
      } else {
        if (a2.back() != a[i]) {
          a2.push_back(a[i]);
        } else {
          if (a1.back() != a[i]) {
            a1.push_back(a[i]);
          }
        }
      }
    }
  }
  if (a1.size() >= 1 && a2.size() >= 1) {
    if (a1.back() == a2.back()) {
      a1.pop_back();
    }
  }
  cout << a1.size() + a2.size() << "\n";
  for (i = 0; i < a1.size(); i++) {
    cout << a1[i] << " ";
  }
  for (i = a2.size() - 1; i >= 0; i--) {
    cout << a2[i] << " ";
  }
  return 0;
}
