This is the easy version of the problem. The difference between the versions is that in the easy version all prices $a_i$ are different. You can make hacks if and only if you solved both versions of the problem.

Today is Sage's birthday, and she will go shopping to buy ice spheres. All $n$ ice spheres are placed in a row and they are numbered from $1$ to $n$ from left to right. Each ice sphere has a positive integer price. In this version all prices are different.

An ice sphere is cheap if it costs strictly less than two neighboring ice spheres: the nearest to the left and the nearest to the right. The leftmost and the rightmost ice spheres are not cheap. Sage will choose all cheap ice spheres and then buy only them.

You can visit the shop before Sage and reorder the ice spheres as you wish. Find out the maximum number of ice spheres that Sage can buy, and show how the ice spheres should be reordered.


-----Input-----

The first line contains a single integer $n$ $(1 \le n \le 10^5)$ — the number of ice spheres in the shop.

The second line contains $n$ different integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 10^9)$ — the prices of ice spheres.


-----Output-----

In the first line print the maximum number of ice spheres that Sage can buy.

In the second line print the prices of ice spheres in the optimal order. If there are several correct answers, you can print any of them.


-----Example-----
Input
5
1 2 3 4 5

Output
2
3 1 4 2 5 


-----Note-----

In the example it's not possible to place ice spheres in any order so that Sage would buy $3$ of them. If the ice spheres are placed like this $(3, 1, 4, 2, 5)$, then Sage will buy two spheres: one for $1$ and one for $2$, because they are cheap.

Difficulty: interview

Starter code:

Solutions:
def mi():
    return map(int, input().split())
 
'''
5
1 2 3 4 5
'''
for _ in range(1):
    n = int(input())
    a = list(mi())
    a.sort()
    k = 0
    out = [0]*n
    for i in range(1,n,2):
        out[i] = a[k]
        k+=1
    for i in range(0,n,2):
        out[i] = a[k]
        k+=1
    ans = 0
    a = out
    for i in range(1,n-1):
        if a[i]<a[i-1] and a[i]<a[i+1]:
            ans+=1
    print (ans)
    print (*out)

n = int(input())
l = list(map(int,input().split()))
l.sort()
f = 0
for i in range(n-1):
    if f==0:
        l[i],l[i+1] = l[i+1],l[i]
        f = 1
    else:
        f = 0
ans = (n-1)//2
print(ans)
print(*l)

def read_line():
    return list(map(int, input().split()))

n = int(input())
l = sorted(read_line())
ans = [0] * n
idx = 0
for i in range(1, n, 2):
    ans[i] = l[idx]
    idx += 1
for i in range(0, n, 2):
    ans[i] = l[idx]
    idx += 1
v = 0
for i in range(1, n-1):
    if ans[i-1] > ans[i] and ans[i] < ans[i+1]:
        v += 1
print(v)
print(" ".join(map(str, ans)))



import sys
input = sys.stdin.readline

n = int(input())
x = sorted(list(map(int, input().split())))
a, b = x[:n//2], x[n//2:]
tmp = []
for i in range(n//2):
    tmp.append(b[i])
    tmp.append(a[i])
if n % 2:
    tmp.append(b[-1])
cnt = 0
for i in range(1, n-1, 2):
    if tmp[i+1] > tmp[i] < tmp[i-1]:
        cnt += 1
print(cnt)
print(*tmp)


n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
x = a[:n//2]
a = a[n//2:]
l,k,m = [],0,0
for i in range(n):
     if i%2==0:
          l.append(a[k])
          k+=1
     else:
          l.append(x[m])
          m+=1
m=0
for i in range(1,n-1):
     if(l[i]<l[i-1] and l[i]<l[i+1]):
          m+=1
print(m)   
for i in l:
     print(i,end=" ")
     
     

n=int(input())
s=sorted(map(int,input().split()))
ans=[]
i=0;j=n-1
for _ in range(n):
	if _%2==0:ans.append(s[j]);j-=1
	else:ans.append(s[i]);i+=1
res=0
for i in range(1,n-1):res+=ans[i-1]>ans[i]<ans[i+1]
print(res)
print(*ans)


n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=[0]*n
for i in range(n//2):
  ans[1+i*2]=a[i]
for i in range(n//2,n):
  ans[(i-n//2)*2]=a[i]
co=0
for i in range(1,n-1):
  if ans[i-1]>ans[i] and ans[i]<ans[i+1]:co+=1
print(co)
print(*ans)


n=int(input())
a=list(map(int,input().split()))
a=sorted(a)
for i in range(0,len(a)-1,2):
    a[i],a[i+1] = a[i+1],a[i]
ans = 0
#print(a)
for i in range(0,len(a)-1):
    if a[i]<a[i-1] and a[i]<a[i+1]:
        ans+=1
print(ans)
for i in range(len(a)):
    if i!=len(a)-1:
        print(a[i],end=" ")
    else:
        print(a[i])
#print()


n = int(input())
l = list(map(int,input().split()))
l.sort()
duze = 0
male = 0
print((n-1)//2)
odp = []
for i in range(n):
    if i%2 == 0:
        odp.append(l[n-1-duze])
        duze += 1
    else:
        odp.append(l[male])
        male += 1
print(*odp)

n = int(input())
l = list(map(int,input().split()))
print((n-1)//2)
l.sort()

for i in range(n//2):
    print(l[n-i-1],end=" ")
    print(l[i],end=" ")
if n%2 == 1:
    print(l[n//2],end = " ")
print()

n = int(input())
print((n-1)//2)
a = [int(i) for i in input().split(" ")]
a.sort()
b = []
for i in range(n):
  if i%2 == 0:
    b.append(a[n//2+i//2])
  else:
    b.append(a[i//2])
print(" ".join([str(i) for i in b]))

n = int(input())
u = sorted(list(map(int, input().split())))
print((n - 1) // 2)
ans = []
ind = 0
for i in range((n - 1) // 2, n):
    ans.append(u[i])
    if ind == (n - 1) // 2:
        continue
    ans.append(u[ind])
    ind += 1
print(' '.join(map(str, ans)))


n=int(input())
a=sorted(map(int,input().split()))
print((n-1)//2)
for i in range(n):print(a[(1-i%2)*(n//2)+i//2],end=' ')

n = int(input())
arr = list(map(int, input().split()))
arr.sort()
for i in range(0, n-1, 2):
    arr[i], arr[i+1] = arr[i+1], arr[i]
print((n-1)//2)
print(*arr)


n = int(input())
a = list(map(int, input().split()))
a.sort()
print((n - 1) // 2)
for i in range(1, n, 2):
    a[i], a[i - 1] = a[i - 1], a[i]
print(*a)


import sys
input = sys.stdin.readline


n = int(input())
a = list(map(int, input().split()))

res = [0] * n
a = sorted(a, reverse=True)
ai = 0

for i in range(0, n, 2):
    res[i] = a[ai]
    ai += 1
for i in range(1, n, 2):
    res[i] = a[ai]
    ai += 1
print((n - 1) // 2)
print(*res)