Let's define $p_i(n)$ as the following permutation: $[i, 1, 2, \dots, i - 1, i + 1, \dots, n]$. This means that the $i$-th permutation is almost identity (i.e. which maps every element to itself) permutation but the element $i$ is on the first position. Examples:  $p_1(4) = [1, 2, 3, 4]$;  $p_2(4) = [2, 1, 3, 4]$;  $p_3(4) = [3, 1, 2, 4]$;  $p_4(4) = [4, 1, 2, 3]$. 

You are given an array $x_1, x_2, \dots, x_m$ ($1 \le x_i \le n$).

Let $pos(p, val)$ be the position of the element $val$ in $p$. So, $pos(p_1(4), 3) = 3, pos(p_2(4), 2) = 1, pos(p_4(4), 4) = 1$.

Let's define a function $f(p) = \sum\limits_{i=1}^{m - 1} |pos(p, x_i) - pos(p, x_{i + 1})|$, where $|val|$ is the absolute value of $val$. This function means the sum of distances between adjacent elements of $x$ in $p$.

Your task is to calculate $f(p_1(n)), f(p_2(n)), \dots, f(p_n(n))$.


-----Input-----

The first line of the input contains two integers $n$ and $m$ ($2 \le n, m \le 2 \cdot 10^5$) — the number of elements in each permutation and the number of elements in $x$.

The second line of the input contains $m$ integers ($m$, not $n$) $x_1, x_2, \dots, x_m$ ($1 \le x_i \le n$), where $x_i$ is the $i$-th element of $x$. Elements of $x$ can repeat and appear in arbitrary order.


-----Output-----

Print $n$ integers: $f(p_1(n)), f(p_2(n)), \dots, f(p_n(n))$.


-----Examples-----
Input
4 4
1 2 3 4

Output
3 4 6 5 

Input
5 5
2 1 5 3 5

Output
9 8 12 6 8 

Input
2 10
1 2 1 1 2 2 2 2 2 2

Output
3 3 



-----Note-----

Consider the first example:

$x = [1, 2, 3, 4]$, so  for the permutation $p_1(4) = [1, 2, 3, 4]$ the answer is $|1 - 2| + |2 - 3| + |3 - 4| = 3$;  for the permutation $p_2(4) = [2, 1, 3, 4]$ the answer is $|2 - 1| + |1 - 3| + |3 - 4| = 4$;  for the permutation $p_3(4) = [3, 1, 2, 4]$ the answer is $|2 - 3| + |3 - 1| + |1 - 4| = 6$;  for the permutation $p_4(4) = [4, 1, 2, 3]$ the answer is $|2 - 3| + |3 - 4| + |4 - 1| = 5$. 

Consider the second example:

$x = [2, 1, 5, 3, 5]$, so  for the permutation $p_1(5) = [1, 2, 3, 4, 5]$ the answer is $|2 - 1| + |1 - 5| + |5 - 3| + |3 - 5| = 9$;  for the permutation $p_2(5) = [2, 1, 3, 4, 5]$ the answer is $|1 - 2| + |2 - 5| + |5 - 3| + |3 - 5| = 8$;  for the permutation $p_3(5) = [3, 1, 2, 4, 5]$ the answer is $|3 - 2| + |2 - 5| + |5 - 1| + |1 - 5| = 12$;  for the permutation $p_4(5) = [4, 1, 2, 3, 5]$ the answer is $|3 - 2| + |2 - 5| + |5 - 4| + |4 - 5| = 6$;  for the permutation $p_5(5) = [5, 1, 2, 3, 4]$ the answer is $|3 - 2| + |2 - 1| + |1 - 4| + |4 - 1| = 8$.

Difficulty: HARD

Solutions:
import math
import functools
from collections import defaultdict
(n, m) = map(int, input().split(' '))
v = [i for i in map(int, input().split(' '))]
s = [0 for i in range(n + 2)]
for i in range(m - 1):
	if abs(v[i] - v[i + 1]) < 2:
		continue
	s[min(v[i], v[i + 1]) + 1] += 1
	s[max(v[i], v[i + 1])] -= 1
p = 0
for i in range(m - 1):
	p += abs(v[i] - v[i + 1])
ans = [0 for i in range(n + 2)]
d = 0
for i in range(n + 2):
	d += s[i]
	ans[i] = d
a = defaultdict(lambda : 0, {})
b = defaultdict(lambda : [], {})
for i in range(m - 1):
	if v[i] == v[i + 1]:
		continue
	a[min(v[i], v[i + 1])] += 1
	b[max(v[i], v[i + 1])].append(min(v[i], v[i + 1]))
for i in range(1, n + 1):
	q = p
	q = ans[i]
	q = a[i] * (i - 1)
	q = len(b[i]) * i
	q = 2 * sum(b[i])
	print(p - ans[i] + a[i] * (i - 1) - len(b[i]) * i + 2 * sum(b[i]), end=' ')


import os
from io import BytesIO, IOBase
import sys
from collections import deque

def main():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	c = [a[0]]
	for i in range(1, m):
		if a[i] != c[-1]:
			c.append(a[i])
	(a, m) = (c, len(c))
	b = [[] for _ in range(n + 1)]
	for (i, v) in enumerate(a):
		b[v].append(i + 1)
	a.insert(0, 0)
	pos = [i for i in range(n + 1)]
	z = 0
	for i in range(1, m):
		z += abs(pos[a[i]] - pos[a[i + 1]])
	ans = [z]
	for i in range(2, n + 1):
		for j in b[i - 1]:
			if j > 1:
				z -= abs(pos[a[j - 1]] - pos[i - 1])
			if j + 1 <= m:
				z -= abs(pos[a[j + 1]] - pos[i - 1])
		for j in b[i]:
			if j > 1 and a[j - 1] != i - 1:
				z -= abs(pos[a[j - 1]] - pos[i])
			if j + 1 <= m and a[j + 1] != i - 1:
				z -= abs(pos[a[j + 1]] - pos[i])
		(pos[i], pos[i - 1]) = (pos[i - 1], pos[i])
		for j in b[i - 1]:
			if j > 1:
				z += abs(pos[a[j - 1]] - pos[i - 1])
			if j + 1 <= m:
				z += abs(pos[a[j + 1]] - pos[i - 1])
		for j in b[i]:
			if j > 1 and a[j - 1] != i - 1:
				z += abs(pos[a[j - 1]] - pos[i])
			if j + 1 <= m and a[j + 1] != i - 1:
				z += abs(pos[a[j + 1]] - pos[i])
		ans.append(z)
	print(*ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from collections import defaultdict

def main():
	(n, m) = readIntArr()
	x = readIntArr()
	idxOf = defaultdict(lambda : [])
	for i in range(m):
		idxOf[x[i]].append(i)
	ans = []
	f = 0
	for i in range(m - 1):
		f += abs(x[i] - x[i + 1])
	ans.append(f)
	for i in range(2, n + 1):
		for j in idxOf[1]:
			if j - 1 >= 0:
				f -= abs(x[j - 1] - x[j])
			if j + 1 < m:
				f -= abs(x[j] - x[j + 1])
		for j in idxOf[i]:
			if j - 1 >= 0:
				f -= abs(x[j - 1] - x[j])
			if j + 1 < m:
				f -= abs(x[j] - x[j + 1])
		for j in idxOf[1]:
			x[j] = i
		for j in idxOf[i]:
			x[j] = 1
		temp = idxOf[1]
		idxOf[1] = idxOf[i]
		idxOf[i] = temp
		for j in idxOf[1]:
			if j - 1 >= 0:
				f += abs(x[j - 1] - x[j])
			if j + 1 < m:
				f += abs(x[j] - x[j + 1])
		for j in idxOf[i]:
			if j - 1 >= 0:
				f += abs(x[j - 1] - x[j])
			if j + 1 < m:
				f += abs(x[j] - x[j + 1])
		ans.append(f)
	oneLineArrayPrint(ans)
	return
import sys
input = sys.stdin.buffer.readline

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]

def makeArr(defaultValFactory, dimensionArr):
	dv = defaultValFactory
	da = dimensionArr
	if len(da) == 1:
		return [dv() for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(i, j):
	print('? {} {}'.format(i, j))
	sys.stdout.flush()
	return int(input())

def answerInteractive(ans):
	print('! {}'.format(' '.join([str(x) for x in ans])))
	sys.stdout.flush()
inf = float('inf')
MOD = 10 ** 9 + 7
for _abc in range(1):
	main()


(N, M) = map(int, input().split())
(*X,) = map(int, input().split())
for i in range(M):
	X[i] -= 1
R = 0
S = [0] * N
T = [0] * N
D = [0] * (N + 1)
for i in range(M - 1):
	if X[i] < X[i + 1]:
		D[X[i] + 1] += 1
		D[X[i + 1]] -= 1
	elif X[i] > X[i + 1]:
		D[X[i + 1] + 1] += 1
		D[X[i]] -= 1
	d = abs(X[i] - X[i + 1])
	S[X[i]] += d
	S[X[i + 1]] += d
	if X[i] < X[i + 1]:
		T[X[i]] += X[i + 1]
		T[X[i + 1]] += X[i] + 1
	elif X[i] > X[i + 1]:
		T[X[i]] += X[i + 1] + 1
		T[X[i + 1]] += X[i]
	R += d
for i in range(N - 1):
	D[i + 1] += D[i]
ans = [0] * N
for i in range(N):
	ans[i] = R + T[i] - S[i] - D[i]
print(*ans)


import sys
(n, m) = [int(x) for x in input().split()]
X = [int(x) - 1 for x in input().split()]
s = 0
right = [[] for _ in range(n)]
left = [[] for _ in range(n)]
for j in range(m - 1):
	(a, b) = (X[j], X[j + 1])
	if a == b:
		continue
	if a > b:
		(a, b) = (b, a)
	right[a].append(b)
	left[b].append(a)
	s += b - a
out = [s]
for i in range(1, n):
	for b in right[i - 1]:
		s -= b
	for b in left[i - 1]:
		s -= b + 1
	for b in right[i]:
		s -= b - i
	for b in left[i]:
		s -= i - b - 1
	for b in right[i]:
		s += b
	for b in left[i]:
		s += b + 1
	for b in right[i - 1]:
		s += b - (i - 1) - 1
	for b in left[i - 1]:
		s += i - 1 - b
	out.append(s)
print(' '.join((str(x) for x in out)))