#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, flag = 0;
  vector<int> A, B;
  map<int, int> store;
  store.clear();
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    if (store[a] < 2) {
      if (store[a] == 0) {
        A.push_back(a);
        store[a] = 1;
      } else {
        flag = 1;
        B.push_back(a);
        store[a] = 2;
      }
    }
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  reverse(B.begin(), B.end());
  int ans = A.size() + B.size();
  if (flag)
    if (A[A.size() - 1] == B[0]) ans--;
  cout << ans << endl;
  for (int i = 0; i < A.size(); i++) {
    cout << A[i] << " ";
  }
  for (int i = 0; i < B.size(); i++) {
    if (i == 0 && B[i] == A[A.size() - 1]) continue;
    cout << B[i] << " ";
  }
  cout << endl;
  return 0;
}
