#include <bits/stdc++.h>
using namespace std;
const long long int M = 1000000007;
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res % p;
}
long long int modinver(long long int a, long long int b) {
  return (power(a, 1, M) * power(b, M - 2, M)) % M;
}
void SieveOfEratosthenes(int n) {
  bool prime[10005];
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
}
long long int cum[200003];
long long int ans[200002];
long long int a[200002];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> a[i];
    cum[i] = 0;
  }
  long long int ans1 = 0;
  for (int i = 0; i < m - 1; ++i) {
    long long int x2 = max(a[i], a[i + 1]);
    long long int x1 = min(a[i], a[i + 1]);
    if (x1 == x2) {
      continue;
    }
    ans1 += x2 - x1;
    long long int dif = x2 - x1;
    ans[x1] += x2 - 1 - dif;
    cum[x1 + 1] += x2 - x1 - 1 - dif;
    cum[x2] -= x2 - x1 - 1 - dif;
    ans[x2] += x1 - dif;
  }
  for (int i = 1; i <= n; ++i) {
    cum[i] += cum[i - 1];
    cout << abs(cum[i] + ans[i] + ans1) << " ";
  }
  cout << '\n';
}
