#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  vector<long long> xx(m);
  vector<long long> diff(n + 2, 0);
  for (int i = (0); i < (m); i++) cin >> xx[i];
  for (int i = (0); i < (m - 1); i++) {
    long long xj = min(xx[i], xx[i + 1]);
    long long xj_ = max(xx[i], xx[i + 1]);
    if (xj == xj_) continue;
    diff[xj_ + 1] += xj_ - xj;
    diff[1] += xj_ - xj;
    diff[xj] -= xj_ - xj;
    diff[xj] += xj_ - 1;
    diff[xj + 1] -= xj_ - 1;
    diff[xj_] += xj;
    diff[xj_ + 1] -= xj;
    diff[xj + 1] += xj_ - xj - 1;
    diff[xj_] -= xj_ - xj - 1;
  }
  long long acum = 0;
  for (int i = (0); i < (n + 2); i++) {
    diff[i] += acum;
    acum = diff[i];
  }
  for (int i = (1); i < (n + 1); i++) {
    cout << diff[i] << " ";
  }
  cout << endl;
}
