#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long m;
  cin >> m;
  int b[m], max_no = 0;
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
    max_no = max(max_no, b[i]);
  }
  vector<int> x, y;
  unordered_map<int, long long> mp;
  for (int i = 0; i < m; ++i) {
    mp[b[i]]++;
    if (mp[b[i]] == 1) {
      x.push_back(b[i]);
    } else if (mp[b[i]] == 2 && b[i] != max_no) {
      y.push_back(b[i]);
    }
  }
  sort(x.begin(), x.end(), greater<int>());
  sort(y.begin(), y.end());
  cout << x.size() + y.size() << "\n";
  for (auto s : y) {
    cout << s << " ";
  }
  for (auto s : x) {
    cout << s << " ";
  }
  cout << "\n";
  return 0;
}
