#include <bits/stdc++.h>
using namespace std;
int di[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dj[] = {1, -1, 0, 0, 1, -1, 1, -1};
int arr[5005];
int main() {
  ios_base::sync_with_stdio(false);
  int n, a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    arr[a]++;
  }
  vector<int> ans;
  for (int i = 1; i <= 5000; i++) {
    if (arr[i]) {
      ans.push_back(i);
      arr[i]--;
    }
  }
  for (int i = 5000; i >= 1; i--) {
    if (arr[i] && i != ans.back()) {
      ans.push_back(i);
      arr[i]--;
    }
  }
  cout << ((int)ans.size()) << endl;
  for (int i = 0; i < ((int)ans.size()); i++)
    cout << ans[i] << " \n"[i == ((int)ans.size()) - 1];
  return 0;
}
