#include <bits/stdc++.h>
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
signed main() {
  std::ios::sync_with_stdio(false);
  long long int n, m;
  cin >> n >> m;
  vector<long long int> x(m);
  for (long long int i = 0; i < m; i++) cin >> x[i];
  vector<long long int> arr(200005, 0);
  map<long long int, set<long long int>> mp;
  for (long long int i = 0; i < m; i++) mp[x[i]].insert(i);
  for (long long int i = 1; i < m; i++) {
    long long int t1 = x[i], t2 = x[i - 1];
    long long int tmp1 = t1, tmp2 = t2;
    t1 = min(tmp1, tmp2);
    t2 = max(tmp1, tmp2);
    if (t1 != t2) arr[t1] += 1, arr[t2 + 1] -= 1;
  }
  for (long long int i = 1; i < 200005; i++) arr[i] += arr[i - 1];
  long long int p1 = 0;
  for (long long int i = 1; i < m; i++) p1 += abs(x[i] - x[i - 1]);
  cout << p1 << " ";
  for (long long int i = 2; i < n + 1; i++) {
    long long int pi = p1, cnt = arr[i], pe = 0;
    long long int nog = 0, nos = 0, sum = 0;
    for (auto j : mp[i]) {
      if (j != m - 1 && x[j] < x[j + 1])
        nog++, pe++;
      else if (j != m - 1 && x[j] > x[j + 1])
        nos++, sum += x[j + 1], pe++;
      if (j != 0 && x[j] < x[j - 1])
        nog++, pe++;
      else if (j != 0 && x[j] > x[j - 1])
        nos++, sum += x[j - 1], pe++;
    }
    cnt -= pe;
    pi -= cnt;
    pi += (i - 1) * nog;
    pi += 2 * sum - (i)*nos;
    cout << pi << " ";
  }
}
