#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-5;
const long long MOD = 1000000007LL;
const long long MODS[2] = {1000000007LL, 100003LL};
const int N = 200005;
const int M = 1000005;
long long a[N], b[N], n, m;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> a[i];
  }
  long long sum = 0;
  for (int i = 1; i < m; ++i) sum += abs(a[i] - a[i + 1]);
  b[1] = sum;
  for (int i = 1; i < m; ++i) {
    int u = a[i], v = a[i + 1];
    if (u == v) continue;
    if (u > v) swap(u, v);
    b[u] += u - 1;
    b[u + 1] -= u - 1;
    --b[u + 1];
    ++b[v];
    b[v] += u * 2 - v;
    b[v + 1] -= u * 2 - v;
  }
  for (int i = 1; i <= n; ++i) b[i] += b[i - 1];
  for (int i = 1; i <= n; ++i) cout << b[i] << ' ';
  return 0;
}
