#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  long long cur = 0;
  vector<long long> cnt(n + 1);
  vector<int> prefix(n + 1);
  for (int i = 0; i < m - 1; i++) {
    int l = min(a[i], a[i + 1]);
    int r = max(a[i], a[i + 1]);
    if (l == r) {
      continue;
    }
    prefix[l + 1] += -1, prefix[r] += 1;
    cnt[l] += l - 1;
    cnt[r] += 2 * l - r;
    cur += r - l;
  }
  for (int i = 1; i <= n; i++) {
    prefix[i] += prefix[i - 1];
    cout << cur + prefix[i] + cnt[i] << " ";
  }
  return 0;
}
