#include <bits/stdc++.h>
using namespace std;
int n, m;
long long p[200002], pref[200002];
void add_range(int l, int r, int x) {
  pref[l] += x;
  pref[r + 1] -= x;
}
void calc(int l, int r) {
  int diff = r - l;
  if (l + 1 != r) {
    add_range(l + 1, r - 1, diff - 1);
  }
  if (l) add_range(1, l - 1, diff);
  if (r < n) add_range(r + 1, n, diff);
  add_range(l, l, r - 1);
  add_range(r, r, l);
}
int main() {
  cin.sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> p[i];
    if (i) {
      if (p[i] == p[i - 1]) continue;
      int l = p[i], r = p[i - 1];
      if (r < l) swap(l, r);
      calc(l, r);
    }
  }
  for (int i = 1; i <= n; i++) {
    pref[i] += pref[i - 1];
    cout << pref[i] << ' ';
  }
  cout << '\n';
}
