#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> v(m);
  for (long long i = 0; i < m; i++) cin >> v[i], v[i]--;
  vector<long long> ans(n, 0);
  for (long long i = 0; i < m - 1; i++) {
    long long a = v[i];
    long long b = v[i + 1];
    if (a == b) continue;
    if (b < a) swap(a, b);
    ans[0] += abs(b - a);
    ans[a] -= abs(b - a);
    if (b + 1 < n) ans[b + 1] += abs(b - a);
    ans[a] += abs(b);
    if (a + 1 < n) ans[a + 1] -= abs(b);
    ans[b] += abs(a + 1);
    if (b + 1 < n) ans[b + 1] -= abs(a + 1);
    if (a + 1 < n) ans[a + 1] += abs(b - a - 1);
    ans[b] -= abs(b - a - 1);
  }
  for (int i = 0; i < n - 1; i++) ans[i + 1] = ans[i] + ans[i + 1];
  for (auto a : ans) cout << a << " ";
  cout << endl;
  return 0;
}
