#include <bits/stdc++.h>
using namespace std;
long long n;
long long p[200000];
vector<long long> v1;
vector<long long> v2;
int main() {
  long long i, x, j, k;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> p[i];
  }
  sort(p, p + n);
  if (n == 1) {
    cout << 1 << endl;
    cout << p[0] << endl;
    return 0;
  }
  i = 0;
  v1.push_back(p[i]);
  i++;
  v2.push_back(p[i]);
  for (i = 2; i < n; i++) {
    if (i % 2 == 0) {
      if (v1[v1.size() - 1] == p[i]) {
        continue;
      }
      v1.push_back(p[i]);
    } else {
      if (v2[v2.size() - 1] == p[i]) {
        continue;
      }
      v2.push_back(p[i]);
    }
  }
  if (v1[v1.size() - 1] > v2[v2.size() - 1]) {
    cout << v1.size() + v2.size() << endl;
    for (i = 0; i < v1.size(); i++) {
      cout << v1[i] << " ";
    }
    for (i = v2.size() - 1; i >= 0; i--) {
      cout << v2[i] << " ";
    }
  } else if (v1[v1.size() - 1] < v2[v2.size() - 1]) {
    cout << v1.size() + v2.size() << endl;
    for (i = 0; i < v2.size(); i++) {
      cout << v2[i] << " ";
    }
    for (i = v1.size() - 1; i >= 0; i--) {
      cout << v1[i] << " ";
    }
  } else {
    cout << v1.size() + v2.size() - 1 << endl;
    for (i = 0; i < v2.size(); i++) {
      cout << v2[i] << " ";
    }
    if (v1.size() != 1) {
      for (i = v1.size() - 2; i >= 0; i--) {
        cout << v1[i] << " ";
      }
    }
  }
  return 0;
}
