#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, i, j;
  cin >> n >> m;
  vector<long long int> v;
  long long int sum = 0;
  for (i = 0; i < m; i++) {
    long long int y;
    cin >> y;
    v.push_back(y);
    if (i > 0) {
      sum += abs(v[i] - v[i - 1]);
    }
  }
  vector<long long int> ans(n + 2, 0);
  ans[1] = sum;
  for (i = 0; i < m - 1; i++) {
    long long int l = v[i], r = v[i + 1];
    if (l == r) continue;
    if (r < l) swap(l, r);
    ans[l] += l - 1;
    ans[l + 1] -= l - 1;
    ans[r] += (2 * l) - r;
    ans[r + 1] -= (2 * l) - r;
    ans[l + 1] -= 1;
    ans[r] += 1;
  }
  for (i = 2; i <= n; i++) ans[i] += ans[i - 1];
  for (i = 1; i <= n; i++) cout << ans[i] << " ";
}
