n=int(input())
tab=input()
tabz=[]
k=0
b=0
f=0
h=10
for o in range (0, len(tab)):
    if tab[o]== " ":
        pass
    else:
        tabz.append(int(tab[o]))
    o=o+1
print(max(tabz))
for k in range (0, h):
    rez0=[]
    bu=0
    a=max(tabz)
    for i in range (0,n):
        if (i<n-1 and i>-1):
            if tabz[i]== a:
                tabz[i]=tabz[i]-1
            if (tabz[i-1]==a):
                tabz[i-1]==tabz[i-1]-1

            if (tabz[i+1]==a):
                tabz[i+1]==tabz[i+1]-1
        a=max(tabz)
        if (i==n-1):
            if tabz[i]== a:
                tabz[i]=tabz[i]-1
                bu=1
            if (tabz[i-1]==a):
                tabz[i-1]==tabz[i-1]-1
        a=max(tabz)
        if (i==0 ):
            if tabz[0]== a:
                tabz[0]=tabz[0]-1
                bu=1
            if (tabz[0+1]==a):
                tabz[0+1]==tabz[0+1]-1
        
        
    i=i+1
    for f in range (0,n-1):
        if tabz[f]==0:
            rez0.append(0)
    print(tabz)
    if len(rez0)==n:
        print(k)
        break
k=k+1
