#include <bits/stdc++.h>
int inp() {
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  int sum = 0;
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum;
}
int n, x[200010];
long long ans[200010], sum[200010];
void solve(int a, int b) {
  if (a == b) return;
  if (a > b) std::swap(a, b);
  sum[1] += b - a;
  sum[a] -= b - a;
  sum[b + 1] += b - a;
  sum[a + 1] += (b - a - 1);
  sum[b] -= (b - a - 1);
  ans[a] += b - 1;
  ans[b] += a;
}
int main() {
  n = inp();
  int m = inp();
  for (int i = 1; i <= m; i++) x[i] = inp();
  for (int i = 1; i < m; i++) solve(x[i], x[i + 1]);
  long long tot = 0;
  for (int i = 1; i <= n; i++) {
    tot += sum[i];
    printf("%lld ", tot + ans[i]);
  }
  putchar('\n');
}
