#include <bits/stdc++.h>
using namespace std;
template <class V, class U>
struct SegTree {
  int n;
  vector<V> st;
  vector<U> lazy;
  vector<int> leaves;
  SegTree(const int n) : n(n) {
    leaves.resize(n);
    init(1, 0, n - 1);
    lazy.resize(st.size());
  }
  void init(const int si, const int lo, const int hi) {
    if (lo == hi) {
      if (si >= (int)st.size()) st.resize(si + 1);
      st[si] = V();
      leaves[lo] = si;
    } else {
      const int mid = (lo + hi) >> 1;
      init(si << 1, lo, mid);
      init(si << 1 | 1, mid + 1, hi);
      st[si] = st[si << 1] + st[si << 1 | 1];
    }
  }
  void updateLazy(const int si, const int lo, const int hi) {
    lazy[si].apply(st[si], lo, hi);
    if (lo != hi) {
      lazy[si << 1] = U(lazy[si << 1], lazy[si]);
      lazy[si << 1 | 1] = U(lazy[si << 1 | 1], lazy[si]);
    }
    lazy[si] = U();
  }
  V query(const int l, const int r) {
    return (l <= r && l < n && r >= 0) ? query(l, r, 1, 0, n - 1) : 0;
  }
  V query(const int l, const int r, const int si, const int lo, const int hi) {
    updateLazy(si, lo, hi);
    if (l <= lo && hi <= r) return st[si];
    const int mid = (lo + hi) >> 1;
    if (r <= mid) return query(l, r, si << 1, lo, mid);
    if (mid < l) return query(l, r, si << 1 | 1, mid + 1, hi);
    return V(query(l, r, si << 1, lo, mid),
             query(l, r, si << 1 | 1, mid + 1, hi));
  }
  void update(const int l, const int r, const U u) {
    if (l <= r) update(l, r, u, 1, 0, n - 1);
  }
  void update(const int l, const int r, const U &u, const int si, const int lo,
              const int hi) {
    if (l <= lo && hi <= r) {
      lazy[si] = U(lazy[si], u);
      updateLazy(si, lo, hi);
    } else {
      updateLazy(si, lo, hi);
      if (hi < l || r < lo) return;
      const int mid = (lo + hi) >> 1;
      update(l, r, u, si << 1, lo, mid);
      update(l, r, u, si << 1 | 1, mid + 1, hi);
      st[si] = st[si << 1] + st[si << 1 | 1];
    }
  }
  vector<int> remAll(const int l, const int r) {
    vector<int> res;
    remAll(l, r, 1, 0, n - 1, res);
    return res;
  }
  void remAll(const int l, const int r, const int si, const int lo,
              const int hi, vector<int> &res) {
    updateLazy(si, lo, hi);
    if (!st[si] || hi < l || r < lo) return;
    if (lo == hi) {
      res.push_back(lo);
      st[si] = 0;
    } else {
      const int mid = (lo + hi) >> 1;
      remAll(l, r, si << 1, lo, mid, res);
      remAll(l, r, si << 1 | 1, mid + 1, hi, res);
      st[si] = st[si << 1] + st[si << 1 | 1];
    }
  }
  void updateAllLazy() { updateAllLazy(1, 0, n - 1); }
  void updateAllLazy(const int si, const int lo, const int hi) {
    updateLazy(si, lo, hi);
    if (lo != hi) {
      const int mid = (lo + hi) >> 1;
      updateAllLazy(si << 1, lo, mid);
      updateAllLazy(si << 1 | 1, mid + 1, hi);
    }
  }
  vector<V> retrieve() {
    updateAllLazy();
    vector<V> res(n);
    for (int i = 0; i < n; ++i) res[i] = st[leaves[i]];
    return res;
  }
};
struct StUpdate {
  long long v = 0;
  StUpdate() {}
  StUpdate(const long long v) : v(v) {}
  StUpdate(const StUpdate &u1, const StUpdate &u2) { v = u1 + u2; }
  operator long long() const { return v; }
  void apply(long long &v, const int lo, const int hi) {
    v += this->v * (hi - lo + 1);
  }
};
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  SegTree<long long, StUpdate> st(n + 1);
  vector<long long> v(m);
  for (int i = 0; i < m; i++) cin >> v[i];
  for (int i = 0; i < m - 1; i++) {
    long long a = min(v[i], v[i + 1]);
    long long b = max(v[i], v[i + 1]);
    if (a == b) continue;
    st.update(1, a - 1, b - a);
    st.update(a, a, b - 1);
    st.update(a + 1, b - 1, b - a - 1);
    st.update(b, b, a);
    st.update(b + 1, n, b - a);
  }
  vector<long long> ans = st.retrieve();
  for (int i = 1; i < int((ans).size()); i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
