#include <bits/stdc++.h>
using namespace std;
#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long
#define sz(x) int(x.size())
#define ft first
#define sd second
#define endl '\n'
#define pb push_back
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
void solve()
{
int v[12312];
int n; cin >> n;
for(int i = 0; i < n; i++){
int x; cin >> x;
v[x]++;
}
vector<int> res;
int maxi = 0;
for(int i = 1; i <= 5000; i++)
if(v[i] >= 1){
maxi = i;
v[i]--;
res.push_back(i);
}
for(int i = maxi-1; i >= 1; i--)
if(v[i] >= 1){
v[i]--;
res.push_back(i);
}
cout << res.size() << endl;
for(int val : res)
cout << val << " ";
cout << endl;
}
int32_t main()
{
fst
int ttt=1;
//cin >> ttt;
while(ttt--)
{
solve();
}
return 0;
}
1144D - Equalize Them All | 298A - Snow Footprints |
1753B - Factorial Divisibility | 804A - Find Amir |
1541C - Great Graphs | 607B - Zuma |
30A - Accounting | 959C - Mahmoud and Ehab and the wrong algorithm |
1215A - Yellow Cards | 237B - Young Table |
1216D - Swords | 271D - Good Substrings |
573A - Bear and Poker | 10A - Power Consumption Calculation |
1244B - Rooms and Staircases | 777A - Shell Game |
1698D - Fixed Point Guessing | 415B - Mashmokh and Tokens |
26D - Tickets | 471B - MUH and Important Things |
982B - Bus of Characters | 1102B - Array K-Coloring |
818A - Diplomas and Certificates | 70A - Cookies |
798A - Mike and palindrome | 1690F - Shifting String |
366B - Dima and To-do List | 120B - Quiz League |
740A - Alyona and copybooks | 1491A - K-th Largest Value |