#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using db = long double;
using ii = pair<int, int>;
const int N = 2e5 + 5, LG = 19, MOD = 1e9 + 7;
const int SQ = 225;
const long double EPS = 1e-7;
ll p[N];
ll ans[N];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  for (auto& v : x) {
    cin >> v;
  }
  for (int idx = 1; idx < m; idx++) {
    int i = min(x[idx - 1], x[idx]);
    int j = max(x[idx - 1], x[idx]);
    if (i == j) continue;
    ans[i] += j - 1;
    ans[j] += i;
    p[1] += j - i;
    p[i] -= j - i;
    p[j + 1] += j - i;
    p[n + 1] -= j - i;
    p[i + 1] += j - i - 1;
    p[j] -= j - i - 1;
  }
  for (int i = 1; i < n + 1; i++) p[i] += p[i - 1];
  for (int i = 1; i < n + 1; i++) cout << ans[i] + p[i] << ' ';
  return 0;
}
