#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int m[100005] = {0};
  cin >> n;
  int t;
  int max = 0;
  int k = 0;
  for (int i = 0; i < n; i++) {
    cin >> t;
    m[t]++;
    if (m[t] <= 2) k++;
    if (max < t) max = t;
  }
  int flag = 0;
  if (m[max] > 1) {
    k--;
  }
  cout << k << endl;
  for (int i = 1; i < max; i++) {
    if (m[i] && flag) {
      cout << " " << i;
    } else if (m[i] && !flag) {
      cout << i;
      flag = 1;
    }
  }
  cout << " " << max;
  for (int i = max - 1; i >= 1; i--)
    if (m[i] > 1) cout << " " << i;
  cout << endl;
}
