#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 5;
int n, m, d[M], cnt[M];
vector<int> g[M];
long long ans[M];
int D(int x) { return x > 0 ? x : -x; }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &d[i]);
    if (i > 1) {
      g[d[i]].push_back(d[i - 1]);
      g[d[i - 1]].push_back(d[i]);
      if (D(d[i] - d[i - 1]) > 1)
        cnt[min(d[i], d[i - 1]) + 1]++, cnt[max(d[i], d[i - 1])]--;
      ans[1] += D(d[i] - d[i - 1]);
    }
  }
  for (int i = 1; i <= n; i++) cnt[i] += cnt[i - 1];
  for (int i = 2; i <= n; i++) {
    ans[i] = ans[1] - cnt[i];
    for (auto j : g[i])
      if (j - i) {
        ans[i] -= D(i - j);
        ans[i] += j - (j > i);
      }
  }
  for (int i = 1; i <= n; i++) printf("%I64d%c", ans[i], " \n"[i == n]);
}
