There is a given sequence of integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub>, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
The first line contains an integer *n* (1 ≤ *n* ≤ 10<sup class="upper-index">6</sup>). The second line contains a sequence of integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 3).
N=int(input())
A=list(map(int,input().split()))
ans=0;l=[]
for i in range(N):
    l.append([A[i],i+1])
l.sort(reverse=True)
for i in range(N):
    ans+=l[i][0]*i+1
print(ans)
ans2=''
for i in range(N):
    ans2+=str(l[i][1])+' '
print(ans2[:len(ans2)-1])