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 ≤ n ≤ 10^5) — the number of ice spheres in the shop.

The second line contains n different integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 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.
import heapq as hq
from heapq import heappop,heappush
from collections import deque,defaultdict,Counter
from sys import stdin,stdout


def inp():
	return int(stdin.readline())


def inlt():
	return list(map(int,stdin.readline().split()))


def insr():
	return list(stdin.readline().strip())


def invr():
	return map(int,stdin.readline().split())


def pr(n):
	stdout.write(str(n)+"\n")


def subset_sum_count(arr,n,sum):
	dp=[[0 for _ in range(sum+1)] for _ in range(n+1)]
	for i in range(n+1):
		for j in range(sum+1):
			if j==0:
				dp[i][j]=1
			elif arr[i-1]<=j:
				dp[i][j]=dp[i-1][j-arr[i-1]]+dp[i-1][j]
			else:
				dp[i][j]=dp[i-1][j]
	return dp[n][sum]


def binary_search(func,lo,hi,abs_prec=1e-7):
	""" Locate the first value x s.t. func(x) = True within [lo, hi] """
	while abs(hi-lo)>abs_prec:
		mi=lo+(hi-lo)/2
		if func(mi):
			hi=mi
		else:
			lo=mi
	
	return (lo+hi)/2


def ternary_search(func,lo,hi,abs_prec=1e-7):
	""" Find maximum of unimodal function func() within [lo, hi] """
	while abs(hi-lo)>abs_prec:
		lo_third=lo+(hi-lo)/3
		hi_third=hi-(hi-lo)/3
		
		if func(lo_third)<func(hi_third):
			lo=lo_third
		else:
			hi=hi_third
	
	return (lo+hi)/2


def discrete_binary_search(func,lo,hi):
	""" Locate the first value x s.t. func(x) = True within [lo, hi] """
	while lo<hi:
		mi=lo+(hi-lo)//2
		if func(mi):
			hi=mi
		else:
			lo=mi+1
	
	return lo


def discrete_ternary_search(func,lo,hi):
	""" Find the first maximum of unimodal function func() within [lo, hi] """
	while lo<=hi:
		lo_third=lo+(hi-lo)//3
		hi_third=lo+(hi-lo)//3+(1 if 0<hi-lo<3 else (hi-lo)//3)
		
		if func(lo_third)<func(hi_third):
			lo=lo_third+1
		else:
			hi=hi_third-1
	
	return lo
	
	return -1


def right_rotate(a,s):
	return a[s:]+a[:s]


def dec_to_bin(x):
	return int(bin(x)[2:])


def str_to_integer_list(n):
	a=[]
	for i in range(len(n)):
		a.append(int(n[i]))
	return a


def list_to_str(l):
	s=""
	for i in l:
		s+=str(i)
	return s


def dijkstra(s,N,E):
	visited=set()
	dist={}
	for i in range(1,N+1):
		dist[i]=1<<29
	queue=[(dist[i],i) for i in range(1,N+1)]
	hq.heappush(queue,(0,s))
	dist[s]=0
	while queue:
		d,u=hq.heappop(queue)
		if u in visited:
			continue
		#Relax all the neighbours of u
		for t in E[u]:
			v,r=t
			if dist[v]>d+r:
				dist[v]=d+r
				hq.heappush(queue,(dist[v],v))
		#Node u has been processed
		visited.add(u)
	return dist


def prime_sieve(n):
	"""returns a sieve of primes >= 5 and < n"""
	flag=n%6==2
	sieve=bytearray((n//3+flag>>3)+1)
	for i in range(1,int(n**0.5)//3+1):
		if not (sieve[i>>3]>>(i&7))&1:
			k=(3*i+1)|1
			for j in range(k*k//3,n//3+flag,2*k):
				sieve[j>>3]|=1<<(j&7)
			for j in range(k*(k-2*(i&1)+4)//3,n//3+flag,2*k):
				sieve[j>>3]|=1<<(j&7)
	return sieve


def prime_list(n):
	"""returns a list of primes <= n"""
	res=[]
	if n>1:
		res.append(2)
	if n>2:
		res.append(3)
	if n>4:
		sieve=prime_sieve(n+1)
		res.extend(3*i+1|1 for i in range(1,(n+1)//3+(n%6==1)) if not (sieve[i>>3]>>(i&7))&1)
	return res


def dijkstra(n,graph,start):
	""" Uses Dijkstra's algortihm to find the shortest path between in a graph. """
	dist,parents=[float("inf")]*n,[-1]*n
	dist[start]=0
	queue=[(0,start)]
	while queue:
		path_len,v=heappop(queue)
		if path_len==dist[v]:
			for w,edge_len in graph[v]:
				if edge_len+path_len<dist[w]:
					dist[w],parents[w]=edge_len+path_len,v
					heappush(queue,(edge_len+path_len,w))
	
	return dist,parents


def path(start,end,parent):
	path=[end]
	while path[-1]!=start:
		path.append(parent[path[-1]])
	path.reverse()
	return path


def bfs(graph,start,goal):
	"""
	finds a shortest path in undirected `graph` between `start` and `goal`.
	If no path is found, returns `None`
	"""
	if start==goal:
		return [start]
	visited={start}
	queue=deque([(start,[])])
	
	while queue:
		current,path=queue.popleft()
		visited.add(current)
		for neighbor in graph[current]:
			if neighbor==goal:
				return path+[current,neighbor]
			if neighbor in visited:
				continue
			queue.append((neighbor,path+[current]))
			visited.add(neighbor)
	return None  # no path found. not strictly needed


def fillPrefixSum(arr,n,prefixSum):
	prefixSum[0]=arr[0]
	
	# Adding present element
	# with previous element
	for i in range(1,n):
		prefixSum[i]=prefixSum[i-1]+arr[i]


def check(a,ind,d1):
	beg=a[:ind+1]
	end=a[ind+1:]
	d=[]
	c=0
	for i in end:
		if i-d1 in beg:
			c+=1
	return c


'''for _ in range(int(input())):
	n,m=list(map(int,input().split()))
	graph=defaultdict(list)
	distance=[-1]*(n+1)
	visited=[False]*(n+1)
	for _ in range(m):
		x,y=list(map(int,input().split()))
		graph[x].append(y)
		graph[y].append(x)'''
'''for _ in range(int(input())):
	n,m=list(map(int,input().split()))
	graph=[[]for _ in range(n+1)]
	distance=[-1]*(n+1)
	visited=[False]*(n+1)
	for _ in range(m):
		x,y,w=list(map(int,input().split()))
		graph[x].append([y,w])
		graph[y].append([x,w])'''

import os
import sys
from io import BytesIO,IOBase


def DecimalToBinary(n):
	def helper(n):
		if n==0:
			return ''  # <- empty string
		else:
			if n%2==1:
				binaryDigit='1'
			else:
				binaryDigit='0'
			return helper(n//2)+binaryDigit
	
	if n==0:
		result='0'  # <- "leading zero" only for `n == 0`
	else:
		result=helper(n)
	return result


def p(board):
	for i in range(8):
		s=""
		for j in range(8):
			s+=board[i][j]
		print(s)


def binaryToDecimal(n):
	return int(n,2)


def decimalToBinary(n):
	return bin(n).replace("0b","")


def solve(a,b):
	x=DecimalToBinary(a);
	y=DecimalToBinary(b)
	z=x+y
	l=y+x
	
	r=binaryToDecimal(z)-binaryToDecimal(l)
	return r


def mostFrequent(arr,n):
	# Sort the array
	arr.sort()
	
	# find the max frequency using
	# linear traversal
	max_count=1;
	res=arr[0];
	curr_count=1
	
	for i in range(1,n):
		if (arr[i]==arr[i-1]):
			curr_count+=1
		
		else:
			if (curr_count>max_count):
				max_count=curr_count
				res=arr[i-1]
			
			curr_count=1
	
	# If last element is most frequent
	if (curr_count>max_count):
		max_count=curr_count
		res=arr[n-1]
	
	return res


from bisect import bisect_right,bisect_left


def lds(arr,n):
	lds=[0]*n
	max=0
	
	for i in range(n):
		lds[i]=1
	
	for i in range(1,n):
		for j in range(i):
			if (arr[i]<arr[j] and
					lds[i]<lds[j]+1):
				lds[i]=lds[j]+1
	
	for i in range(n):
		if (max<lds[i]):
			max=lds[i]
	
	# returns the length of the LDS
	return max


import math


def prefix(a):
	pre=[]
	pre.append(a[0])
	for i in range(1,len(a)):
		pre.append(pre[i-1]+a[i])
	return pre
def solve(n,x,size):
	res=10000000
	if n==0:
		return 0
	if size==0:
		return 0
	for i in x:
		
		res=1+min(res,solve(n-i,x,size-1))
		return res

def main():
	n=inp()
	a=inlt()
	a.sort(reverse=True)
	if n>3:
		y=(n-2)//2;x=(n-2)-y
		res=[]
		res[:]=[a[0]]+a[2:2+y]+[a[1]]
		k=1
		for i in range(2+y,n):
			res.insert(k,a[i])
			k+=2
		print(x)
		print(*res)
	elif n<=2:
		print(0)
		print(*a)
	elif n==3:
		a[1],a[2]=a[2],a[1]
		print(1)
		print(*a)
		

	
	
	
	
		
		

# region fastio
BUFSIZE=8192


class FastIO(IOBase):
	newlines=0
	
	def __init__(self,file):
		self._fd=file.fileno()
		self.buffer=BytesIO()
		self.writable="x" in file.mode or "r" not in file.mode
		self.write=self.buffer.write if self.writable else None
	
	def read(self):
		while True:
			b=os.read(self._fd,max(os.fstat(self._fd).st_size,BUFSIZE))
			if not b:
				break
			ptr=self.buffer.tell()
			self.buffer.seek(0,2),self.buffer.write(b),self.buffer.seek(ptr)
		self.newlines=0
		return self.buffer.read()
	
	def readline(self):
		while self.newlines==0:
			b=os.read(self._fd,max(os.fstat(self._fd).st_size,BUFSIZE))
			self.newlines=b.count(b"\n")+(not b)
			ptr=self.buffer.tell()
			self.buffer.seek(0,2),self.buffer.write(b),self.buffer.seek(ptr)
		self.newlines-=1
		return self.buffer.readline()
	
	def flush(self):
		if self.writable:
			os.write(self._fd,self.buffer.getvalue())
			self.buffer.truncate(0),self.buffer.seek(0)


class IOWrapper(IOBase):
	def __init__(self,file):
		self.buffer=FastIO(file)
		self.flush=self.buffer.flush
		self.writable=self.buffer.writable
		self.write=lambda s:self.buffer.write(s.encode("ascii"))
		self.read=lambda:self.buffer.read().decode("ascii")
		self.readline=lambda:self.buffer.readline().decode("ascii")


sys.stdin,sys.stdout=IOWrapper(sys.stdin),IOWrapper(sys.stdout)
input=lambda:sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__=="__main__":
	main()

