#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long exp(long long a, long long b, long long m) {
  if (b == 0) return 1;
  if (b == 1) return mod(a, m);
  long long k = mod(exp(a, b / 2, m), m);
  if (b & 1) {
    return mod(a * mod(k * k, m), m);
  } else
    return mod(k * k, m);
}
long long f[200100];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m;
  cin >> n >> m;
  vector<long long> x(m);
  for (long long i = 0; i < m; i++) {
    cin >> x[i];
  }
  for (long long i = 0; i < m - 1; i++) {
    long long mx = max(x[i + 1], x[i]);
    long long mn = min(x[i + 1], x[i]);
    if (mx == mn) continue;
    f[1] += mx - mn;
    f[mn] -= mx - mn;
    f[mn] += mx - 1;
    f[mn + 1] -= mx - 1;
    f[mn + 1] += mx - mn - 1;
    f[mx] -= mx - mn - 1;
    f[mx] += mn;
    f[mx + 1] -= mn;
    f[mx + 1] += mx - mn;
    f[n + 1] -= mx - mn;
  }
  for (long long i = 1; i <= n; i++) {
    f[i] += f[i - 1];
  }
  for (long long i = 1; i <= n; i++) {
    cout << f[i] << " ";
  }
  cout << endl;
}
