#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  vector<long long> a(m);
  for (long long i = 0; i < m; i++) cin >> a[i];
  long long s = ceil(sqrt(n));
  vector<vector<long long> > v(s, vector<long long>(s, 0));
  vector<long long> an(s, 0);
  for (long long i = 0; i < m - 1; i++) {
    long long f = min(a[i], a[i + 1]), l = max(a[i], a[i + 1]);
    if (f == l) continue;
    long long x = f / s, y = l / s;
    if (f % s == 0) x--;
    if (l % s == 0) y--;
    long long r = f % s, t = l % s;
    r--;
    t--;
    if (r < 0) r = s - 1;
    if (t < 0) t = s - 1;
    for (long long j = x + 1; j < y; j++) an[j]--;
    if (x != y) {
      for (long long j = r + 1; j < s; j++) v[x][j]--;
      for (long long j = 0; j < t; j++) v[y][j]--;
    } else {
      for (long long j = r + 1; j < t; j++) v[y][j]--;
    }
    v[x][r] += f - 1;
    v[y][t] += 2 * f - l;
  }
  long long sum = 0;
  for (long long i = 0; i < m - 1; i++) {
    sum += max(a[i + 1], a[i]) - min(a[i + 1], a[i]);
  }
  for (long long i = 1; i <= n; i++) {
    long long x = i / s;
    if (i % s == 0) x--;
    long long r = i % s;
    r--;
    if (r < 0) r = s - 1;
    cout << sum + an[x] + v[x][r] << " ";
  }
  return 0;
}
