#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> p[200123];
long long v[200123], ans[200123];
int n, m;
int main() {
  long long ant;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; ++i) {
    scanf("%lld", &v[i]);
  }
  p[0].first = min(v[0], v[1]);
  p[0].second = max(v[0], v[1]);
  for (int i = 2; i < m; ++i) {
    p[i - 1].first = min(v[i], v[i - 1]);
    p[i - 1].second = max(v[i], v[i - 1]);
  }
  for (int i = 0; i < m - 1; ++i) {
    if (p[i].first != p[i].second) {
      if (p[i].first > 1) {
        ans[1] += p[i].second - p[i].first;
        ans[p[i].first] -= p[i].second - p[i].first;
      }
      ans[p[i].first] += p[i].second - 1;
      ans[p[i].first + 1] -= p[i].second - 1;
      ans[p[i].first + 1] += p[i].second - p[i].first - 1;
      ans[p[i].second] -= p[i].second - p[i].first - 1;
      ans[p[i].second] += p[i].first;
      ans[p[i].second + 1] -= p[i].first;
      ans[p[i].second + 1] += p[i].second - p[i].first;
    }
  }
  printf("%lld", ans[1]);
  for (int i = 2; i <= n; ++i) {
    ans[i] += ans[i - 1];
    printf(" %lld", ans[i]);
  }
  printf("\n");
  return 0;
}
