#include <bits/stdc++.h>
using namespace std;
int n, m, x[200010];
int main() {
  cin >> n >> m;
  vector<long long> ans(200010, 0ll);
  for (int i = 0; i < m; i++) {
    scanf("%d", x + i);
  }
  for (int i = 0; i < m - 1; i++) {
    int mi = min(x[i], x[i + 1]);
    int ma = max(x[i], x[i + 1]);
    if (mi == ma) continue;
    ans[0] += ma - mi;
    if (ma - mi > 1) {
      ans[mi] += mi - 1;
      ans[mi + 1] = ans[mi + 1] - mi;
      ans[ma] = ans[ma] + mi - (ma - mi - 1);
      ans[ma + 1] = ans[ma + 1] + ma - 2 * mi;
    } else {
      ans[mi] += mi - 1;
      ans[mi + 2] = ans[mi + 2] - mi + 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    ans[i] += ans[i - 1];
    cout << ans[i] << " ";
  }
}
