#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
long long n, m, x, y, s, d[N], t[N];
void dj(long long xx, long long yy) {
  if (xx == yy) return;
  if (xx > yy) {
    long long z = xx;
    xx = yy;
    yy = z;
  }
  s += yy - xx;
  d[xx] += xx - 1;
  d[yy] += 2 * xx - yy;
  --t[xx + 1];
  ++t[yy];
}
int main() {
  scanf("%lld%lld%lld", &n, &m, &x);
  for (long long i = 1; i < m; ++i) scanf("%lld", &y), dj(x, y), x = y;
  for (long long i = 1; i <= n; ++i) s += t[i], printf("%lld ", s + d[i]);
  return 0;
}
