#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
long long s[N * 4], lazy[N * 4];
int pre[N];
void pu(int o, int l, int r) {
  if (lazy[o]) {
    lazy[o * 2] += lazy[o];
    lazy[o * 2 + 1] += lazy[o];
    s[o * 2] += 1ll * ((l + r) / 2 + 1 - l) * lazy[o];
    s[o * 2 + 1] += 1ll * (r - (l + r) / 2) * lazy[o];
    lazy[o] = 0;
  }
}
long long qu(int o, int l, int r, int pos) {
  if (l == r) return s[o];
  pu(o, l, r);
  if (pos <= (l + r) / 2)
    return qu(o * 2, l, (l + r) / 2, pos);
  else
    return qu(o * 2 + 1, (l + r) / 2 + 1, r, pos);
}
void up(int o, int l, int r, int ql, int qr, int val) {
  if (ql > qr) return;
  if (ql <= l && qr >= r) {
    lazy[o] += val;
    s[o] += 1ll * (r - l + 1) * val;
    return;
  }
  pu(o, l, r);
  if (ql <= (l + r) / 2) up(o * 2, l, (l + r) / 2, ql, qr, val);
  if (qr > (l + r) / 2) up(o * 2 + 1, (l + r) / 2 + 1, r, ql, qr, val);
  s[o] = s[o * 2] + s[o * 2 + 1];
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) scanf("%d", &pre[i]);
  for (int i = 2; i <= m; ++i) {
    int l = pre[i - 1];
    int r = pre[i];
    if (l > r) swap(l, r);
    if (l == r) continue;
    up(1, 1, n, l, l, r - 1);
    up(1, 1, n, r, r, l);
    up(1, 1, n, l + 1, r - 1, r - l - 1);
    up(1, 1, n, 1, l - 1, r - l);
    up(1, 1, n, r + 1, n, r - l);
  }
  for (int i = 1; i <= n; ++i) printf("%lld ", qu(1, 1, n, i));
}
