#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  map<int, int> a;
  while (n--) {
    int x;
    scanf("%d", &x);
    a[x]++;
  }
  vector<int> ans;
  for (auto i : a) ans.push_back(i.first);
  for (auto i = a.rbegin(); i != a.rend(); i++)
    if (i->second > 1 && i != a.rbegin()) ans.push_back(i->first);
  printf("%d\n", ans.size());
  for (int i : ans) printf("%d ", i);
  return 0;
}
