#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int n, m, x[maxn], diff[maxn];
long long f[maxn];
inline void Input() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) cin >> x[i];
}
inline int Pos(const int &p, const int &val) {
  if (p == val) return 1;
  if (p < val) return val;
  return val + 1;
}
inline int Abs(const int &x) { return (x < 0) ? -x : x; }
inline void Solve() {
  long long temp = 0;
  for (int i = 1; i < m; i++) {
    temp += (diff[i] = Abs(Pos(1, x[i]) - Pos(1, x[i + 1])));
  }
  for (int i = 1; i < m; i++) {
    if (x[i] == x[i + 1]) continue;
    int a = min(x[i], x[i + 1]);
    int b = max(x[i], x[i + 1]);
    if (b - a != 1) {
      f[a + 1]--;
      f[b]++;
    }
    f[a] += Pos(1, b) - 1 - Abs(Pos(1, x[i]) - Pos(1, x[i + 1]));
    f[a + 1] -= Pos(1, b) - 1 - Abs(Pos(1, x[i]) - Pos(1, x[i + 1]));
    f[b] += Pos(1, a) - Abs(Pos(1, x[i]) - Pos(1, x[i + 1]));
    f[b + 1] -= Pos(1, a) - Abs(Pos(1, x[i]) - Pos(1, x[i + 1]));
  }
  for (int i = 1; i <= n; i++) f[i] += f[i - 1];
  for (int i = 1; i <= n; i++) cout << f[i] + temp << ' ';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  if (fopen("TEST"
            ".INP",
            "r"))
    freopen(
        "TEST"
        ".INP",
        "r", stdin),
        freopen(
            "TEST"
            ".OUT",
            "w", stdout);
  auto start = chrono::steady_clock::now();
  Input();
  Solve();
  auto end = chrono::steady_clock::now();
  cerr << "\nIn milliseconds : "
       << chrono::duration_cast<chrono::milliseconds>(end - start).count();
  cerr << '\n'
       << "In seconds : " << fixed << setprecision(3)
       << (double)chrono::duration_cast<chrono::milliseconds>(end - start)
                  .count() /
              1000
       << '\n';
  return 0;
}
