#include <bits/stdc++.h>
using namespace std;
long long a[200008], res[200008];
int main() {
  long long n, m;
  scanf("%lld", &n);
  scanf("%lld", &m);
  long long i, j, k, l;
  for (i = 0; i < m; i++) scanf("%lld", &a[i]);
  for (i = 0; i < m - 1; i++) {
    k = min(a[i], a[i + 1]);
    l = max(a[i], a[i + 1]);
    if (k == l) continue;
    int p1, p2;
    p1 = l - k;
    p2 = l - k - 1;
    res[1] += p1;
    res[k] -= p1;
    res[l + 1] += p1;
    res[n + 1] -= p1;
    res[k + 1] += p2;
    res[l] -= p2;
    res[k] += l - 1;
    res[k + 1] -= l - 1;
    res[l] += k + 1 - 1;
    res[l + 1] -= k + 1 - 1;
  }
  long long ans = 0;
  for (i = 1; i <= n; i++) {
    ans += res[i];
    cout << ans << " ";
  }
  return 0;
}
