#include <bits/stdc++.h>
using namespace std;
void Quick_sort(int a[], int l, int r) {
  for (int i = l; i < r; i++)
    for (int j = i + 1; j <= r; j++)
      if (a[i] > a[j]) swap(a[i], a[j]);
}
int main() {
  srand(time(0));
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  stable_sort(a, a + n);
  vector<int> b, c;
  b.push_back(a[0]);
  for (int i = 1; i < n; i++)
    if (a[i] != b.back())
      b.push_back(a[i]);
    else
      c.push_back(a[i]);
  for (long long i = c.size(); i > 0; i--)
    if (c[i - 1] != b.back()) b.push_back(c[i - 1]);
  cout << b.size() << endl;
  for (unsigned i = 0; i < b.size(); i++) printf("%d ", b[i]);
}
