#include <bits/stdc++.h>
using namespace std;
long long sum[200009], par[200009], a[200009], n, m;
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(0);
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) cin >> a[i];
  for (int i = 1; i < m; i++) {
    long long x = a[i], y = a[i - 1];
    if (x < y) swap(x, y);
    if (x == y) continue;
    sum[y] += x - 1;
    sum[x] += y;
    par[0] += x - y;
    par[y] -= x - y;
    par[y + 1] += x - y - 1;
    par[x] -= x - y - 1;
    par[x + 1] += x - y;
  }
  for (int i = 1; i <= n; i++) {
    par[i] += par[i - 1];
    sum[i] += par[i];
    cout << sum[i] << " ";
  }
}
