#include <bits/stdc++.h>
using namespace std;
int compare(const void* a, const void* b) { return (*(int*)a - *(int*)b); }
int main() {
  vector<int> v;
  int n, i, j, temp;
  cin >> n;
  int a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  qsort(a, n, sizeof(int), compare);
  int flag = 0;
  for (i = 0; i < n; i++) {
    v.push_back(a[i]);
    while (i < n - 1 && a[i] == a[i + 1]) {
      i++;
      flag = 1;
    }
    if (flag) {
      v.push_back(a[i]);
      flag = 0;
    }
  }
  i = v.size() - 1;
  while (i > 0 && v[i] == v[i - 1]) {
    v.pop_back();
    i--;
  }
  n = v.size();
  cout << n << endl;
  for (i = 0; i < n; i += 2) cout << v[i] << " ";
  if (n % 2)
    n = n - 2;
  else
    n = n - 1;
  for (j = n; j >= 0; j -= 2) cout << v[j] << " ";
  return 0;
}
