#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, a[100005], b[100005], ans[100005];
  while (cin >> m) {
    for (int i = 0; i < m; i++) cin >> a[i];
    sort(a, a + m);
    int num1 = 0, num2 = 0;
    ans[num1++] = a[0];
    for (int i = 1; i < m; i++)
      if (a[i] != a[i - 1])
        ans[num1++] = a[i];
      else
        b[num2++] = a[i];
    sort(b, b + num2);
    for (; num2 > 0; num2--)
      if (b[num2 - 1] != a[m - 1]) break;
    if (num2 != 0) ans[num1++] = b[num2 - 1];
    for (int i = num2 - 2; i >= 0; i--)
      if (b[i] != b[i + 1]) ans[num1++] = b[i];
    cout << num1 << endl;
    for (int i = 0; i < num1; i++) cout << ans[i] << " ";
    cout << endl;
  }
  return 0;
}
