#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
long long a[maxn], ans[maxn];
vector<int> v[maxn];
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%lld", &a[i]);
  }
  for (int i = 1; i <= m - 1; i++) {
    long long l = a[i], r = a[i + 1];
    if (l > r) swap(l, r);
    if (l == r) continue;
    ans[1] += r - l, ans[l] -= r - l;
    ans[r + 1] += r - l, ans[n + 1] -= r - l;
    ans[l] += r - 1, ans[l + 1] -= r - 1;
    ans[r] += l, ans[r + 1] -= l;
    ans[l + 1] += r - l - 1, ans[r] -= r - l - 1;
  }
  for (int i = 1; i <= n; i++) {
    ans[i] += ans[i - 1];
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
}
