#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef std::vector<pll> vpll;
void boost() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
template <typename T>
void scan(T &x) {
  x = 0;
  bool neg = 0;
  register T c = getchar();
  if (c == '-') neg = 1, c = getchar();
  while ((c < 48) || (c > 57)) c = getchar();
  for (; c < 48 || c > 57; c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) x = (x << 3) + (x << 1) + (c & 15);
  if (neg) x *= -1;
}
template <typename T>
void print(T n) {
  bool neg = 0;
  if (n < 0) n *= -1, neg = 1;
  char snum[65];
  int i = 0;
  do {
    snum[i++] = n % 10 + '0';
    n /= 10;
  } while (n);
  --i;
  if (neg) putchar('-');
  while (i >= 0) putchar(snum[i--]);
  putchar(' ');
}
ll cnt[5005];
void solve() {
  ll i, n, x, maxi = -(ll)2e15, ans = 0;
  scan(n);
  for (i = 0; i < n; i++) {
    scan(x);
    maxi = max(maxi, x);
    if (cnt[x] == 2) continue;
    cnt[x]++;
    ans++;
  }
  if (cnt[maxi] == 2) --ans, --cnt[maxi];
  print(ans);
  putchar('\n');
  for (i = 1; i <= 5000; i++) {
    if (cnt[i] >= 1) {
      print(i);
      cnt[i]--;
    }
  }
  for (i = 5000; i >= 1; i--) {
    if (cnt[i] >= 1) {
      print(i);
      cnt[i]--;
    }
  }
}
int main() {
  boost();
  ll t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
