#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using llu = long long unsigned;
using ld = long double;
const ld EPS = 1e-9;
inline int cmp(ld first, ld second = 0, ld tol = EPS) {
  return (first <= second + tol) ? (first + tol < second) ? -1 : 0 : 1;
}
const int MOD = 1;
inline int mod(ll first, int m = MOD) { return (int)(((first % m) + m) % m); }
const int N = 2e5 + 10;
int n, m;
ll first[N], chg[N], one[N];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) scanf("%lld", &first[i]);
  ll base = 0;
  for (int i = 1; i < m; i += 2) {
    base += abs(first[i] - first[i - 1]);
    if (i < m - 1) base += abs(first[i] - first[i + 1]);
  }
  for (int i = 0; i < m; i++) {
    if (i < m - 1) {
      if (first[i + 1] > first[i]) {
        chg[first[i]]--;
        one[first[i]] += first[i] - 1;
      }
      if (first[i + 1] < first[i]) {
        chg[first[i]]++;
        ll dBef = abs(first[i] - (first[i + 1] + 1));
        ll dNow = abs(1 - (first[i + 1] + 1));
        one[first[i]] += (dNow - dBef);
      }
    }
    if (i) {
      if (first[i - 1] > first[i]) {
        chg[first[i]]--;
        one[first[i]] += first[i] - 1;
      }
      if (first[i - 1] < first[i]) {
        chg[first[i]]++;
        ll dBef = abs(first[i] - (first[i - 1] + 1));
        ll dNow = abs(1 - (first[i - 1] + 1));
        one[first[i]] += (dNow - dBef);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%lld ", base);
    base -= one[i];
    base += chg[i] + one[i + 1];
  }
  putchar('\n');
  return 0;
}
