#include <bits/stdc++.h>
using namespace std;
long long a[200005], b[200005];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
  }
  int x, y;
  for (int i = 1; i < m; i++) {
    x = b[i];
    y = b[i + 1];
    if (x == y) continue;
    if (y < x) swap(x, y);
    if (x > 1) {
      a[1] += (y - x);
      a[x] -= (y - x);
    }
    a[x] += (y - 1);
    a[x + 1] -= (y - 1);
    if (y - x > 1) {
      a[x + 1] += (y - x - 1);
      a[y] -= (y - x - 1);
    }
    a[y] += (x);
    a[y + 1] -= (x);
    a[y + 1] += (y - x);
    a[n + 1] -= (y - x);
  }
  for (int i = 1; i <= n; i++) a[i] += a[i - 1];
  for (int i = 1; i <= n; i++) cout << a[i] << " ";
}
