#include <bits/stdc++.h>
using namespace std;
int a[111111];
map<int, int> cnt;
map<int, int> m;
int main() {
  int n;
  scanf("%d", &n);
  m.clear();
  cnt.clear();
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  int ma = INT_MIN;
  for (int i = 0; i < n; i++) {
    m[a[i]] += 1;
    ma = max(ma, a[i]);
  }
  vector<int> v;
  for (int i = 0; i < n; i++)
    if (cnt[a[i]] != 1) {
      v.push_back(a[i]);
      cnt[a[i]] = 1;
      m[a[i]] = m[a[i]] - 1;
    }
  cnt.clear();
  for (int i = n - 1; i >= 0; i--)
    if (a[i] != ma && m[a[i]] > 0 && cnt[a[i]] != 1) {
      v.push_back(a[i]);
      cnt[a[i]] = 1;
    }
  printf("%d\n", v.size());
  for (int i = 0; i < v.size(); i++) printf("%d ", v[i]);
  printf("\n");
  return 0;
}
