#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
long long n, m, a[N];
pair<long long, long long> p[N];
int tot;
long long cf[N], num1[N], num2[N], sum1[N], sum2[N];
long long sum = 0;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) cin >> a[i];
  for (int i = 1; i <= m - 1; i++) {
    int x = a[i], y = a[i + 1];
    if (x > y) swap(x, y);
    if (x == y) continue;
    p[++tot] = make_pair(x, y);
    sum += y - x;
    num1[x]++;
    sum1[x] += y - x;
    num2[y]++;
    sum2[y] += y - x;
    cf[x]++;
    cf[y + 1]--;
  }
  for (int i = 1; i <= n; i++) cf[i] = cf[i - 1] + cf[i];
  vector<long long> ans;
  ans.push_back(sum);
  for (int i = 2; i <= n; i++) {
    long long a1 = 0, a2 = 0, ans2 = sum;
    a1 = i * num2[i] - sum2[i];
    a2 = (i - 1) * num1[i] + sum1[i];
    sum = sum - sum2[i] + a1 - sum1[i] + a2;
    long long res = cf[i] - num1[i] - num2[i];
    sum -= res;
    ans.push_back(sum);
    sum = ans2;
  }
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  cout << endl;
}
