#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 7;
long long n, m;
long long x[N], a[N], y[N];
vector<int> v1[N], v2[N];
int main() {
  scanf("%I64d%I64d", &n, &m);
  for (long long i = 1; i <= m; i++) {
    scanf("%I64d", &a[i]);
  }
  long long ans = 0;
  for (long long i = 1; i < m; i++) {
    long long j = i + 1;
    long long t1 = a[i], t2 = a[j];
    if (t1 > t2) swap(t1, t2);
    x[i] = t1, y[i] = t2;
  }
  for (long long i = 1; i < m; i++) {
    v1[x[i]].push_back(i);
    v2[y[i]].push_back(i);
    ans += y[i] - x[i];
  }
  long long k = 1, cnt = 0;
  for (long long i = 1; i <= n; i++) {
    for (auto v : v2[i]) {
      if (y[v] == x[v]) continue;
      ans -= abs(y[v] - x[v]);
      ans += x[v];
      cnt--;
    }
    ans -= cnt;
    cnt = 0;
    for (auto v : v2[i - 1]) {
      if (y[v] == x[v]) continue;
      ans -= x[v];
      ans += abs(y[v] - x[v]);
    }
    for (auto v : v1[i - 1]) {
      if (y[v] == x[v]) continue;
      ans -= y[v] - 1;
      ans += abs(y[v] - x[v]);
    }
    for (auto v : v1[i]) {
      if (y[v] == x[v]) continue;
      ans -= abs(y[v] - x[v]);
      ans += y[v] - 1;
      cnt++;
    }
    cout << ans << " ";
  }
  return 0;
}
