#include <bits/stdc++.h>
using namespace std;
long long n, m, x[200001], f[200001];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x[i];
  }
  for (int i = 0; i < m - 1; i++) {
    long long l = min(x[i], x[i + 1]);
    long long r = max(x[i], x[i + 1]);
    if (l == r) continue;
    f[1] += r - l;
    f[l] += l - 1;
    f[l + 1] += -l;
    f[r] += 2 * l + 1 - r;
    f[r + 1] += -2 * l + r;
    f[n + 1] += l - r;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += f[i];
    cout << ans << " ";
  }
}
