#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string &s, char c) {
  vector<string> v;
  stringstream second(s);
  string x;
  while (getline(second, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << ", ";
  err(++it, args...);
}
int ini() {
  int x;
  scanf("%d", &x);
  return x;
}
long long inl() {
  long long x;
  scanf("%lld", &x);
  return x;
}
double ind() {
  double x;
  scanf("%lf", &x);
  return x;
}
int set_1(int n, int pos) { return n = (n | (1 << pos)); }
int reset_0(int n, int pos) { return n = n & ~(1 << pos); }
bool check_bit(int n, int pos) { return n = n & (1 << pos); }
int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};
const int N = (int)1e6 + 5;
const int M = (int)1e9 + 7;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
int a[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1, te = 0;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    int res = 0;
    int in = n;
    while (a[in] == a[n]) {
      --in;
    }
    set<int> middle_to_right, left_to_middle;
    for (int i = in + 1; i >= 1; i--) {
      if (middle_to_right.count(a[i]) == 1 and
          left_to_middle.count(a[i]) == 0) {
        left_to_middle.insert(a[i]);
        res++;
      } else if (middle_to_right.count(a[i]) == 0) {
        middle_to_right.insert(a[i]);
        res++;
      }
    }
    set<int>::iterator it;
    std::vector<int> v;
    printf("%d\n", res);
    for (it = left_to_middle.begin(); it != left_to_middle.end(); ++it) {
      printf("%d ", *it);
    }
    for (it = middle_to_right.begin(); it != middle_to_right.end(); ++it) {
      v.push_back(*it);
    }
    for (int i = (int)v.size() - 1; i >= 0; i--) {
      printf("%d ", v[i]);
    }
  }
  return 0;
}
