#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool umax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
template <typename T, typename U>
bool compare(T x, U y) {
  return (abs(x - y) <= 1e-9);
}
map<int, int> mp;
int n;
vector<int> ans;
void solve() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    mp[x]++;
  }
  for (auto x : mp) {
    ans.push_back(x.first);
    mp[x.first]--;
  }
  auto it = mp.rbegin();
  it++;
  for (; it != mp.rend(); it++) {
    if (it->second) {
      ans.push_back(it->first);
    }
  }
  cout << ans.size() << "\n";
  for (auto x : ans) cout << x << " ";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
}
