#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vll>;
using vb = vector<bool>;
const int INF = 2e9 + 5;
const ll LLINF = (1LL << 60) + 5;
void range_add(vector<ll> &v, int l, int r, int k) {
  if (l > r) return;
  if (l >= 1 && l < v.size()) v[l] += k;
  if (r + 1 >= 1 && r + 1 < v.size()) v[r + 1] -= k;
}
int main() {
  cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  vector<int> v(m);
  for (int &i : v) cin >> i;
  vector<ll> f(n + 1);
  for (int i = 0; i + 1 < m; i++) {
    int a = v[i], b = v[i + 1];
    if (a > b) swap(a, b);
    if (a == b) continue;
    range_add(f, 1, a - 1, b - a);
    range_add(f, b + 1, n, b - a);
    range_add(f, a, a, b - 1);
    range_add(f, b, b, a);
    range_add(f, a + 1, b - 1, b - a - 1);
  }
  partial_sum(f.begin(), f.end(), f.begin());
  for (int i = 1; i <= n; i++) cout << f[i] << ' ';
  return cout << endl, 0;
}
