#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 20;
int n, a[N], pv;
bool vis[N];
vector<int> ans;
void add(int i) {
  pv = a[i];
  vis[i] = true;
  ans.push_back(a[i]);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  for (int i = 0; i < n; i++)
    if (a[i] > pv) add(i);
  for (int i = n - 1; i >= 0; i--)
    if (a[i] < pv and not vis[i]) add(i);
  printf("%d\n", ans.size());
  for (auto i : ans) printf("%d ", i);
}
