#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int m;
  cin >> m;
  vector<int> va;
  while (m--) {
    int x;
    cin >> x;
    va.push_back(x);
  }
  sort(va.begin(), va.end());
  vector<int> ans;
  vector<bool> vis;
  for (auto &i : va) {
    if (ans.empty() || ans.back() < i) {
      vis.push_back(true);
      ans.push_back(i);
    } else {
      vis.push_back(false);
    }
  }
  reverse(va.begin(), va.end());
  reverse(vis.begin(), vis.end());
  for (int i = 0; i < va.size(); i++) {
    if (!vis[i]) {
      if (ans.empty() || ans.back() > va[i]) {
        ans.push_back(va[i]);
      }
    }
  }
  cout << ans.size() << endl;
  for (auto &i : ans) {
    cout << i << " ";
  }
  return 0;
}
