#include <bits/stdc++.h>
using namespace std;
int main() {
  int m;
  cin >> m;
  int numbers[m];
  for (int i = 0; i < m; i++) {
    cin >> numbers[i];
  }
  sort(numbers, numbers + m);
  int largest = numbers[m - 1];
  set<int> firstPart, secondPart;
  secondPart.insert(largest);
  for (int i = m - 2; i >= 0; i--) {
    if (numbers[i] != largest) {
      if (numbers[i + 1] == numbers[i]) {
        firstPart.insert(numbers[i]);
      } else
        secondPart.insert(numbers[i]);
    }
  }
  vector<int> ans;
  for (auto it = firstPart.begin(); it != firstPart.end(); it++) {
    ans.push_back(*it);
  }
  for (auto it = prev(secondPart.end()); it != secondPart.begin(); it--) {
    ans.push_back(*it);
  }
  auto it = secondPart.begin();
  ans.push_back(*it);
  cout << ans.size() << endl;
  for (auto it = ans.begin(); it != ans.end(); it++) {
    cout << *it << " ";
  }
}
