#include <bits/stdc++.h>
using namespace std;
const int LEN = 100001;
int m, a[LEN], b[LEN << 1];
int main() {
  while (scanf("%d", &m) != EOF) {
    for (int i = 0; i < m; ++i) {
      scanf("%d", &a[i]);
    }
    sort(a, a + m);
    memset(b, -1, sizeof(b));
    int pre = 0, flag = 0, lef = 0, rig = m - 1, cnt = 0;
    for (int i = 0; i < m; ++i) {
      if (pre == a[i]) {
        if (flag == 1) {
          b[rig--] = a[i];
          ++cnt;
          ++flag;
        }
      } else {
        b[lef++] = a[i];
        ++cnt;
        if (a[i] == a[m - 1]) break;
        pre = a[i];
        flag = 1;
      }
    }
    printf("%d\n%d", cnt, b[0]);
    for (int i = 1; i < m; ++i) {
      if (b[i] != -1) printf(" %d", b[i]);
    }
    puts("");
  }
  return 0;
}
