N, M = map(int, input().split()) A = list(map(int, input().split())) inf = 10 ** 18 dp = [inf] * N dp[0] = 0 def f(X): Y = [inf] * N for i in range(N): for j in range(N): Y[i] = min(Y[i], X[j] + abs(j-i)) return Y dp = f(dp) for a in A[::-1]: dp[a-1], dp[a] = dp[a], dp[a-1] dp = f(dp) print(*dp[1:])