#include <bits/stdc++.h>
using namespace std;
int a[100010];
vector<int> ans;
int main() {
  int n, cur = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  for (int i = 0; i < n; i++)
    if (a[i] > cur) {
      cur = a[i];
      ans.push_back(cur);
      a[i] = 5001;
    }
  for (int i = n - 1; i >= 0; i--)
    if (a[i] < cur) {
      cur = a[i];
      ans.push_back(cur);
    }
  int l = ans.size();
  printf("%d\n", l);
  for (int i = 0; i < l; i++) printf("%d%c", ans[i], i == l - 1 ? '\n' : ' ');
  return 0;
}
