#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
void scan() {}
template <typename F, typename... R>
void scan(F& f, R&... r) {
  cin >> f;
  scan(r...);
}
int di_;
string dnms_, co_ = ",";
void debug_() { cout << endl; }
template <typename F, typename... R>
void debug_(F& f, R&... r) {
  while (dnms_[di_] != ',') cout << dnms_[di_++];
  di_++;
  cout << ": " << f << ",";
  debug_(r...);
}
template <class A, class B>
ostream& operator<<(ostream& out, const pair<A, B>& a) {
  return out << "(" << a.first << "," << a.second << ")";
}
template <class A>
ostream& operator<<(ostream& out, const vector<A>& a) {
  out << "";
  for (auto it = a.begin(); it != a.end(); it++) {
    if (it != a.begin()) out << " ";
    out << *it;
  }
  out << "";
  return out;
}
template <class A, class B>
istream& operator>>(istream& in, pair<A, B>& a) {
  in >> a.first >> a.second;
  return in;
}
template <class A>
istream& operator>>(istream& in, vector<A>& a) {
  for (A& i : a) in >> i;
  return in;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<long long int> v(m);
  cin >> v;
  vector<long long int> a(n + 2, 0);
  for (int i = 0; i < m - 1; ++i) {
    long long int xi = v[i];
    long long int xi1 = v[i + 1];
    if (xi == xi1) continue;
    if (xi1 < xi) swap(xi1, xi);
    if (xi > 1) {
      a[1] += xi1 - xi;
      a[xi] -= xi1 - xi;
    }
    a[xi] += xi1 - 1;
    a[xi + 1] -= xi1 - 1;
    if (xi1 - xi - 1 > 0) {
      a[xi + 1] += xi1 - xi - 1;
      a[xi1] -= xi1 - xi - 1;
    }
    a[xi1] += xi;
    a[xi1 + 1] -= xi;
    if ((n - xi1) > 0) {
      a[xi1 + 1] += xi1 - xi;
      a[n + 1] -= xi1 - xi;
    }
  }
  for (int i = 1; i < n + 2; ++i) {
    a[i] += a[i - 1];
  }
  for (int i = 1; i <= n; ++i) {
    cout << a[i] << " ";
  }
  return 0;
}
