#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int x[N], cnt[N];
long long f[N];
vector<int> adj[N];
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(f, 0, sizeof(f));
    memset(cnt, 0, sizeof(cnt));
    memset(x, 0, sizeof(x));
    for (int i = 1; i <= n; i++) adj[i].clear();
    for (int i = 1; i <= m; i++) scanf("%d", &x[i]);
    for (int i = 1; i < m; i++) f[1] += abs(x[i] - x[i + 1]);
    for (int i = 1; i < m; i++) {
      int a = x[i], b = x[i + 1];
      if (a != b) {
        adj[a].push_back(b);
        adj[b].push_back(a);
      }
      if (a > b) swap(a, b);
      if (b - a < 2) continue;
      cnt[a + 1]++;
      cnt[b]--;
    }
    for (int i = 2; i <= n; i++) cnt[i] += cnt[i - 1];
    for (int i = 2; i <= n; i++) {
      f[i] = f[1] - cnt[i];
      for (int j = 0; j < adj[i].size(); j++) {
        f[i] -= abs(adj[i][j] - i);
        f[i] += adj[i][j] - 1 + (adj[i][j] < i);
      }
    }
    for (int i = 1; i <= n; i++) printf("%lld%c", f[i], i == n ? '\n' : ' ');
  }
  return 0;
}
