#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  long long a[m];
  for (long long i = 0; i < m; i++) {
    cin >> a[i];
  }
  vector<long long> vc(n + 1);
  for (long long i = 1; i < m; i++) {
    long long x = min(a[i], a[i - 1]), y = max(a[i], a[i - 1]);
    if (x == y) {
      continue;
    }
    if (y + 1 <= n) {
      vc[y + 1] += y - x;
    }
    if (x - 1 >= 1) {
      vc[1] += y - x;
      vc[x] -= y - x;
    }
    if (x + 1 <= y - 1) {
      vc[x + 1] += y - x - 1;
      vc[y] -= y - x - 1;
    }
    vc[x] += y - 1;
    vc[x + 1] -= y - 1;
    vc[y] += x;
    if (y + 1 <= n) {
      vc[y + 1] -= x;
    }
  }
  long long sm = 0;
  for (long long o = 1; o <= n; o++) {
    sm += vc[o];
    cout << sm << " ";
  }
  cout << endl;
}
