#include <bits/stdc++.h>
using namespace std;
const long long int N = 3 * 1e6 + 2;
long long int n, k;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long int m;
  cin >> n >> m;
  vector<long long int> v(m);
  for (long long int i = 0; i < m; i++) cin >> v[i];
  vector<long long int> pref(n + 5, 0);
  vector<long long int> res(n + 5, 0);
  for (long long int i = 0; i < m - 1; i++) {
    long long int x = v[i], y = v[i + 1];
    if (x > y) swap(x, y);
    if (x == y) {
      continue;
    }
    pref[1] += (y - x);
    pref[x] -= (y - x);
    pref[y + 1] += (y - x);
    pref[n + 1] -= (y - x);
    res[x] += (y - 1);
    res[y] += x;
    pref[x + 1] += (y - x - 1);
    pref[y] -= (y - x - 1);
  }
  for (long long int i = 1; i <= n; ++i) pref[i] += pref[i - 1];
  for (long long int i = 1; i <= n; ++i)
    cout << pref[i] + res[i] << " \n"[i == n];
  return 0;
}
