#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<long long> x(m);
  for (long long i = 0; i < m; i++) cin >> x[i];
  long long base = 0;
  for (long long i = 0; i < m - 1; i++) base += abs(x[i + 1] - x[i]);
  vector<long long> add(n + 1);
  vector<long long> addans(n + 1);
  vector<pair<long long, long long>> great(n + 1), les(n + 1);
  for (long long i = 0; i < m - 1; i++) {
    long long l = min(x[i], x[i + 1]), r = max(x[i], x[i + 1]);
    if (l == r) continue;
    great[l].first++, great[l].second += r;
    les[r].first++, les[r].second += l;
    if (l + 1 <= r - 1) {
      add[l + 1]++;
      add[r - 1 + 1]--;
    }
  }
  long long now = 0;
  for (long long i = 0; i < n + 1; i++) now += add[i], addans[i] = now;
  for (long long i = 0; i < n + 1; i++) {
    if (i == 0) continue;
    long long ANS = base - addans[i];
    ANS -= ((1ll * les[i].first * i) - les[i].second);
    ANS -= (great[i].second - 1ll * great[i].first * i);
    ANS += les[i].second;
    ANS += (great[i].second) - great[i].first;
    cout << ANS << ' ';
  }
  return 0;
}
