#include <bits/stdc++.h>
using namespace std;
void inp(int *n) {
  int t = 0;
  char ch = getchar();
  int sign = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') sign = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    t = (t << 3) + (t << 1) + ch - '0', ch = getchar();
  t = t * sign;
  *n = t;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> in;
  for (int i = 0; i < n; i++) {
    int temp;
    scanf("%d", &temp);
    in.push_back(temp);
  }
  sort(in.begin(), in.end());
  vector<int> pe, baad;
  int lar = in[n - 1], recp = 0, recb = 0, tot = 1;
  for (int j = n - 2; j >= 0; j--) {
    if (in[j] == lar) {
      continue;
    } else {
      if (recb != in[j]) {
        baad.push_back(in[j]);
        recb = in[j];
        tot++;
      } else if (recp != in[j]) {
        pe.push_back(in[j]);
        recp = in[j];
        tot++;
      }
    }
  }
  printf("%d\n", tot);
  for (int k = pe.size() - 1; k >= 0; k--) {
    printf("%d ", pe[k]);
  }
  printf("%d ", lar);
  for (int z = 0; z < baad.size(); z++) {
    printf("%d ", baad[z]);
  }
  return 0;
}
