#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 50;
long long ans[MAXN], sum[MAXN], a[MAXN];
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  long long bas = 0;
  for (int i = 1; i <= m; i++) {
    cin >> a[i];
  }
  for (int i = 2; i <= m; i++) {
    if (a[i] == a[i - 1]) continue;
    int tmp = abs(a[i] - a[i - 1]);
    bas += tmp;
    if (a[i] > a[i - 1]) {
      ans[a[i - 1]] += a[i] - 1 - tmp;
      ans[a[i]] += a[i - 1] - tmp;
    } else if (a[i - 1] > a[i]) {
      ans[a[i - 1]] += a[i] - tmp;
      ans[a[i]] += a[i - 1] - tmp - 1;
    }
    int l = min(a[i - 1], a[i]), r = max(a[i - 1], a[i]);
    sum[l + 1]--;
    sum[r]++;
  }
  for (int i = 1; i <= n; i++) {
    sum[i] += sum[i - 1];
  }
  for (int i = 1; i <= n; i++) {
    cout << bas + sum[i] + ans[i] << ' ';
  }
  cout << endl;
}
