Sage’s Birthday (easy version) SOLUTION
This is the simple variant of the issue. The distinction between the renditions is that in the simple form all costs ai are unique. You can make hacks if and just in the event that you tackled the two renditions of the issue.
Today is Sage’s birthday, and she will go out on the town to shop to purchase ice circles. All n ice circles are put in succession and they are numbered from 1 to n from left to right. Each ice circle has a positive number cost. In this form all costs are extraordinary.
An ice circle is modest on the off chance that it costs carefully under two neighboring ice circles: the closest to one side and the closest to one side. The furthest left and the furthest right ice circles are not modest. Sage will pick all modest ice circles and afterward purchase just them.
You can visit the shop before Sage and reorder the ice circles as you wish. Discover the greatest number of ice circles that Sage can purchase, and show how the ice circles ought to be reordered.
The primary line contains a solitary whole number n (1≤n≤105) — the quantity of ice circles in the shop.
The subsequent line contains n various numbers a1,a2,… ,a (1≤ai≤109) — the costs of ice circles.
In the primary line print the most extreme number of ice circles that Sage can purchase.
In the subsequent line print the costs of ice circles in the ideal request. In the event that there are a few right answers, you can print any of them.
1 2 3 4 5
3 1 4 2 5
In the model it’s unrealistic to put in ice circles in any request so Sage would purchase 3 of them. On the off chance that the ice circles are put this way (3,1,4,2,5), at that point Sage will purchase two circles: one for 1 and one for 2, since they are modest.