#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int add(int a, int b) {
  long long x = a + b;
  if (x >= 1000000007) x -= 1000000007;
  if (x < 0) x += 1000000007;
  return x;
}
long long mul(long long a, long long b) { return (a * b) % 1000000007; }
long long pw(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return ans;
}
int n, m;
int v[200002];
long long mars[200002];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) cin >> v[i];
  for (int i = 1; i < m; ++i) {
    if (v[i] == v[i + 1]) continue;
    int x = v[i];
    int y = v[i + 1];
    if (x > y) swap(x, y);
    mars[1] += y - x;
    mars[x] -= y - x;
    mars[x] += (y - 1);
    mars[x + 1] -= (y - 1);
    mars[x + 1] += (y - x - 1);
    mars[y] -= (y - x - 1);
    mars[y] += x;
    mars[y + 1] -= x;
    mars[y + 1] += (y - x);
  }
  for (int i = 2; i <= n; ++i) mars[i] += mars[i - 1];
  for (int i = 1; i <= n; ++i) cout << mars[i] << " ";
  return 0;
}
