#include <bits/stdc++.h>
using namespace std;
const long long LLINF = 9223372036854775807LL;
const int INF = 2147483647;
const int MOD = 1000000007;
const double eps = 1e-7;
const double PI = acos(-1.0);
int dr[] = {1, 0, -1, 0, -1, 1, 1, -1};
int dc[] = {0, -1, 0, 1, 1, 1, -1, -1};
int m;
pair<int, int> arr[100005];
vector<int> v;
bool done[100005];
bool cf(pair<int, int> a, pair<int, int> b) { return a.first > b.first; }
int main() {
  scanf("%d", &m);
  for (int(i) = (1); (i) <= (m); (i)++)
    scanf("%d", &arr[i].first), arr[i].second = i;
  sort(arr + 1, arr + 1 + m);
  int cur = arr[1].first;
  done[arr[1].second] = true;
  v.push_back(cur);
  for (int(i) = (2); (i) <= (m); (i)++) {
    if (arr[i].first > cur) {
      cur = arr[i].first;
      done[arr[i].second] = true;
      v.push_back(cur);
    }
  }
  sort(arr + 1, arr + 1 + m, cf);
  for (int(i) = (1); (i) <= (m); (i)++) {
    if (arr[i].first < cur && !done[arr[i].second]) {
      cur = arr[i].first;
      v.push_back(cur);
    }
  }
  cout << (int)(v.size()) << endl;
  for (int(i) = (0); (i) < ((int)(v.size())); (i)++) printf("%d ", v[i]);
  puts("");
  return 0;
}
