#include <bits/stdc++.h>
using namespace std;
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
long long inf = 1e18, MOD = 1e9 + 7;
const int nax = 2e5 + 10;
vector<int> adj[nax];
int func(int j, int num) {
  if (num > j) return num;
  if (num < j) return num + 1;
  return 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int ti = 1;
  while (ti--) {
    int n, m;
    cin >> n >> m;
    vector<int> in(m + 1);
    for (int i = 1; i <= m; i++) cin >> in[i];
    vector<long long> ans(n + 1);
    for (int i = 1; i <= m; i++) {
      if (i < m) adj[in[i]].push_back(in[i + 1]);
      if (i > 1) adj[in[i]].push_back(in[i - 1]);
    }
    long long cur_ans = 0;
    for (int i = 1; i < m; i++) {
      cur_ans += abs(func(1, in[i]) - func(1, in[i + 1]));
    }
    ans[1] = cur_ans;
    for (int i = 2; i <= n; i++) {
      for (auto j : adj[i - 1]) {
        cur_ans -= abs(func(i - 1, j) - func(i - 1, i - 1));
        cur_ans += abs(func(i, j) - func(i, i - 1));
      }
      for (auto j : adj[i]) {
        cur_ans -= abs(func(i - 1, j) - func(i - 1, i));
        cur_ans += abs(func(i, j) - func(i, i));
      }
      ans[i] = cur_ans;
    }
    for (int i = 1; i <= n; i++) cout << ans[i] << " ";
    cout << endl;
  }
  return 0;
}
