#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<long long> x, res;
vector<vector<long long> > g;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  x.resize(m);
  for (int i = 0; i < m; ++i) {
    cin >> x[i];
    --x[i];
  }
  long long cur = 0;
  g.resize(n);
  for (int i = 1; i < m; ++i) {
    int a = x[i - 1];
    int b = x[i];
    cur += abs(a - b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  res.assign(n, cur);
  for (int i = 1; i < n; ++i) {
    res[i] = res[i - 1];
    int a = i - 1;
    int b = i;
    for (int j = 0; j < g[a].size(); ++j) {
      int to = g[a][j];
      if (to == a || to == b) continue;
      if (to > i) {
        res[i] -= i;
      } else {
        res[i] += (i - 1 - to) - (to + 1);
      }
    }
    for (int j = 0; j < g[b].size(); ++j) {
      int to = g[b][j];
      if (to == a || to == b) continue;
      if (to > i) {
        res[i] += i;
      } else {
        res[i] -= (i - 1 - to) - (to + 1);
      }
    }
  }
  for (int i = 0; i < n; ++i) cout << res[i] << " ";
  return 0;
}
