#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "{" << p.first << "," << p.second << "}";
  return os;
}
const long long N = 2e5 + 10000;
const long long oo = 1e9 + 7;
long long x[N];
long long n, m;
long long Tree[N];
void update(long long idx, long long x, long long n) {
  while (idx <= n) {
    Tree[idx] += x;
    idx += (idx & -idx);
  }
}
long long query(long long idx) {
  long long sum = 0;
  while (idx > 0) {
    sum += Tree[idx];
    idx -= (idx & -idx);
  }
  return sum;
}
void upd(long long l, long long r, long long x) {
  if (l > r) return;
  update(l, x, n + 1);
  update(r + 1, -x, n + 1);
}
long long getval(long long i) { return query(i) - query(i - 1); }
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) cin >> x[i];
  for (long long i = 1; i < m; i++) {
    long long a = x[i];
    long long b = x[i + 1];
    if (a > b) swap(a, b);
    long long diff = b - a;
    if (diff == 0) continue;
    upd(1, a - 1, diff);
    upd(b + 1, n, diff);
    upd(a + 1, b - 1, diff - 1);
    upd(a, a, b - 1);
    upd(b, b, a);
  }
  for (long long i = 1; i <= n; i++) cout << query(i) << " ";
}
