#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long x[200007];
vector<long long> mp[200007];
long long pos_(long long num, long long p) {
  if (num == p) return 1;
  if (num > p) return p + 1;
  if (num < p) return p;
}
signed main() {
  cin >> n >> m;
  long long p;
  cin >> p;
  long long a;
  x[1] = p;
  for (long long i = 2; i <= m; ++i) {
    cin >> a;
    x[i] = a;
    mp[a].push_back(p);
    mp[p].push_back(a);
    p = a;
  }
  long long curr = 0;
  for (long long i = 2; i <= m; ++i) curr += abs(x[i] - x[i - 1]);
  cout << curr << ' ';
  for (long long i = 2; i <= n; ++i) {
    for (auto j : mp[i - 1]) {
      long long c1 = i - 1, c2 = j;
      curr -= abs(pos_(i - 1, c1) - pos_(i - 1, c2));
      curr += abs(pos_(i, c1) - pos_(i, c2));
    }
    for (auto j : mp[i])
      if (j != i - 1) {
        long long c1 = i, c2 = j;
        curr -= abs(pos_(i - 1, c1) - pos_(i - 1, c2));
        curr += abs(pos_(i, c1) - pos_(i, c2));
      }
    cout << curr << ' ';
  }
  return 0;
}
