n,m=map(int,input().split()) a=list(map(int,input().split())) p=[list(range(n))] for i in range(m): y=a[i]-1 p+=[p[-1]] p[-1][y],p[-1][y+1]=p[-1][y+1],p[-1][y] b=[n]*n g=p[-1][0] for i in range(len(p)): y=p[i].index(g) for j in range(n): b[p[i][j]]=min(b[p[i][j]],abs(y-j)) print(*b[1:])