#include <bits/stdc++.h>
using namespace std;
vector<int> v[100001];
int mod = 1000003;
int main() {
  long long n, k = 0, a[1000001] = {0};
  string s, s1;
  vector<int> x, y;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    if (i == 0 || a[i] != a[i - 1]) {
      x.push_back(a[i]);
      if (a[i] != a[n - 1] && a[i + 1] == a[i]) y.push_back(a[i]);
    }
  }
  cout << x.size() + y.size() << endl;
  for (int i = 0; i < x.size(); i++) cout << x[i] << ' ';
  for (int i = y.size() - 1; i >= 0; i--) cout << y[i] << ' ';
}
