#include <bits/stdc++.h>
using namespace std;
int vis[50000];
bool unused[50000];
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    vis[a[i]]++;
    unused[a[i]] = true;
  }
  sort(a, a + n);
  vector<int> res;
  for (int i = 0; i < n; i++) {
    if (vis[a[i]] && unused[a[i]]) {
      res.push_back(a[i]);
      vis[a[i]]--;
      unused[a[i]] = false;
    }
  }
  sort(a, a + n, greater<int>());
  for (int i = 0; i < n; i++) unused[a[i]] = true;
  for (int i = 0; i < n; i++) {
    if (vis[a[i]] && unused[a[i]]) {
      res.push_back(a[i]);
      vis[a[i]]--;
      unused[a[i]] = false;
    }
  }
  int sz = res.size();
  for (int i = 1; i < res.size(); i++)
    if (res[i] == res[i - 1]) {
      sz--;
      continue;
    }
  cout << sz << endl;
  cout << res[0] << " ";
  for (int i = 1; i < res.size(); i++)
    if (res[i] == res[i - 1])
      continue;
    else
      cout << res[i] << " ";
  return 0;
}
