#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1}, dy[] = {1, -1, 0, 0, 1, -1, -1, 1};
inline void cn(long& n) {
  n = 0;
  long ch = getchar();
  int sign = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') sign = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    n = (n << 3) + (n << 1) + ch - '0', ch = getchar();
  n = n * sign;
}
template <class T>
void cmin(T& a, T b) {
  if (b < a) a = b;
}
template <class T>
void cmax(T& a, T b) {
  if (b > a) a = b;
}
template <class T>
int len(const T& c) {
  return (int)c.size();
}
template <class T>
int len(char c[]) {
  return (int)strlen(c);
}
string itos(long n) {
  string s;
  while (n) {
    s += (n % 10 + 48);
    n /= 10;
  }
  reverse(s.begin(), s.end());
  return s;
}
long stoi(string s) {
  long n = 0;
  for (int i(0), _n(len(s)); i < _n; ++i) n = n * 10 + (s[i] - 48);
  return n;
}
void init() {}
int main() {
  ios_base::sync_with_stdio(false);
  long n, ar[5005] = {0}, a, j = 0, k = 0;
  vector<int> aa, aaa;
  set<int> st;
  cin >> n;
  for (int i(0), _n(n); i < _n; ++i) {
    cin >> a;
    if (ar[a] < 2) ar[a]++;
    st.insert(a);
  }
  for (__typeof((st).begin()) it = (st).begin(); it != (st).end(); ++it) {
    a = (*it);
    if (ar[a] == 2) aa.push_back(a);
    aaa.push_back(a);
  }
  j = len(aa);
  k = len(aaa);
  if (ar[aaa[k - 1]] == 2) j--;
  cout << k + j << endl;
  for (int i(0), _n(k); i < _n; ++i) cout << aaa[i] << " ";
  for (int i = j - 1; i >= 0; i--) {
    cout << aa[i] << " ";
  }
  return 0;
}
