Dreamoon likes coloring cells very much.

There is a row of $n$ cells. Initially, all cells are empty (don't contain any color). Cells are numbered from $1$ to $n$.

You are given an integer $m$ and $m$ integers $l_1, l_2, \ldots, l_m$ ($1 \le l_i \le n$)

Dreamoon will perform $m$ operations.

In $i$-th operation, Dreamoon will choose a number $p_i$ from range $[1, n-l_i+1]$ (inclusive) and will paint all cells from $p_i$ to $p_i+l_i-1$ (inclusive) in $i$-th color. Note that cells may be colored more one than once, in this case, cell will have the color from the latest operation.

Dreamoon hopes that after these $m$ operations, all colors will appear at least once and all cells will be colored. Please help Dreamoon to choose $p_i$ in each operation to satisfy all constraints.


-----Input-----

The first line contains two integers $n,m$ ($1 \leq m \leq n \leq 100\,000$).

The second line contains $m$ integers $l_1, l_2, \ldots, l_m$ ($1 \leq l_i \leq n$).


-----Output-----

If it's impossible to perform $m$ operations to satisfy all constraints, print "'-1" (without quotes).

Otherwise, print $m$ integers $p_1, p_2, \ldots, p_m$ ($1 \leq p_i \leq n - l_i + 1$), after these $m$ operations, all colors should appear at least once and all cells should be colored.

If there are several possible solutions, you can print any.


-----Examples-----
Input
5 3
3 2 2

Output
2 4 1

Input
10 1
1

Output
-1

Difficulty: MEDIUM_HARD

Solutions:
(n, m, *l) = map(int, open(0).read().split())
if sum(l) < n or any((i + x > n for (i, x) in enumerate(l))):
	print(-1)
	exit()
for i in range(m - 1):
	l[-i - 2] += l[-i - 1]
print(*[max(i + 1, n - l[i] + 1) for i in range(m)])


def main():
	(n, m) = readIntArr()
	l = readIntArr()
	p = [0 for _ in range(m)]
	left = 1
	ok = True
	for i in range(m):
		right = l[i] + left - 1
		if right > n:
			ok = False
			break
		p[i] = left
		left += 1
	if ok:
		furthestRightCovered = n + 1
		for i in range(m - 1, -1, -1):
			newLeft = furthestRightCovered - 1 + 1 - l[i]
			p[i] = max(p[i], newLeft)
			furthestRightCovered = p[i]
		if p[0] == 1:
			oneLineArrayPrint(p)
		else:
			print(-1)
	else:
		print(-1)
	return
import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

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()]
inf = float('inf')
MOD = 10 ** 9 + 7
main()


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
p = []
paint_remaining = sum(l)
if paint_remaining < n or len(l) + l[len(l) - 1] - 1 > n:
	print(-1)
else:
	firstindex = 1
	p.append(1)
	paint_remaining -= l[0]
	failed = False
	for paint_length in l[1:]:
		if n - firstindex > paint_remaining:
			firstindex = n - paint_remaining + 1
		else:
			firstindex += 1
			if firstindex + paint_length - 1 > n:
				print(-1)
				failed = True
				break
		paint_remaining -= paint_length
		p.append(firstindex)
	if not failed:
		print(*p)


import sys
from array import array
from typing import List, Tuple, TypeVar, Generic, Sequence, Union

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def main():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) < n or m - 1 + a[-1] > n:
		print(-1)
		exit()
	pos = list(range(1, m)) + [n - a[-1] + 1]
	for i in range(m - 2, -1, -1):
		pos[i] = min(pos[i], n - a[i] + 1, pos[i + 1] - 1)
		if pos[i] + a[i] < pos[i + 1]:
			pos[i] = min(n - a[i] + 1, pos[i + 1] - a[i])
	if min(pos) < 1:
		print(-1)
	else:
		print(*pos)
main()


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
ans = [i + 1 for i in range(m)]
ans.append(n + 1)
for i in range(m - 1, -1, -1):
	ans[i] += max(0, ans[i + 1] - ans[i] - l[i])
res = True
ans[m] = 0
l.append(1)
for i in range(m):
	if not 1 <= ans[i] - ans[i - 1] <= l[i - 1]:
		res = False
		break
	if ans[i] > n - l[i] + 1:
		res = False
		break
if res:
	print(*ans[:m])
else:
	print(-1)


(n, m) = map(int, input().split())
li = list(map(int, input().split()))
sumli = sum(li)
if sumli < n:
	print(-1)
else:
	deficiency = n - m
	for i in range(m):
		if i + li[i] > n:
			print(-1)
			break
	else:
		i = n - li[-1]
		deficiency -= li[-1] - 1
		output = [i]
		z = m - 2
		while deficiency > 0:
			deficiency -= li[z] - 1
			if deficiency >= 0:
				output.append(output[-1] - li[z])
			else:
				output.append(output[-1] - deficiency - li[z])
			z -= 1
		for i in range(z, -1, -1):
			output.append(i)
		output.reverse()
		output = list(map(lambda i: i + 1, output))
		print(*output)


(n, m) = map(int, input().split())
lis = list(map(int, input().split()))
p = []
for i in range(m):
	if lis[i] + i <= n:
		p.append(i + 1)
	else:
		print('-1')
		break
else:
	var = 0
	if p[-1] + lis[-1] < n + 1:
		var = n + 1 - p[-1] - lis[-1]
		las = n
		for j in range(1, m):
			p[-j] = las - lis[-j] + 1
			las = p[-j] - 1
			var -= lis[-j - 1] - 1
			if var <= 0:
				break
	if sum(lis) < n:
		print(-1)
	elif var > 0:
		print(-1)
	else:
		for j in p:
			print(j, end=' ')
		print()


def res():
	print(-1)
	exit()
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
idx = []
if sum(l) < n:
	res()
else:
	for i in range(m):
		if i + l[i] > n:
			res()
	for i in range(m - 1, -1, -1):
		if n > min(i, m - 1 - i):
			curr = min(n - i, l[i])
			idx.append(n - curr + 1)
			n -= curr
		else:
			idx.append(n)
			n -= 1
	print(*idx[::-1])


(n, m) = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
suf_sum = [0 for _ in range(m)]
suf_sum[-1] = l[-1]
for i in range(m - 2, -1, -1):
	suf_sum[i] = suf_sum[i + 1] + l[i]
if sum(l) < n:
	print(-1)
else:
	done = False
	for i in range(m):
		if l[i] + i > n:
			print(-1)
			done = True
			break
	if not done:
		p = [None for _ in range(m)]
		for i in range(m):
			p[i] = max(i, n - suf_sum[i])
		print(' '.join([str(_ + 1) for _ in p]))


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
if sum(l) < n:
	print(-1)
	exit(0)
for i in range(m):
	if n - l[i] < i:
		print(-1)
		exit(0)
p = [0] * m
fr = n
for i in range(m - 1, -1, -1):
	p[i] = max(fr - l[i], i) + 1
	fr = p[i] - 1
print(*p)


(N, M) = list(map(int, input().split()))
L = list(map(int, input().split()))
if sum(L) < N:
	print(-1)
elif any([l + i > N for (i, l) in enumerate(L)]):
	print(-1)
else:
	S = [L[-1]]
	for i in list(reversed(L))[1:]:
		S.append(S[-1] + i)
	S = list(reversed(S))
	res = []
	for (num, (s, l)) in enumerate(zip(S, L)):
		if N - num >= s:
			for ss in S[num:]:
				res.append(N - ss + 1)
			break
		else:
			res.append(num + 1)
	print(' '.join(map(str, res)))


import sys
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
if sum(l) < n:
	print(-1)
	sys.exit(0)
pre = [1] * (m + 1)
max = m + l[-1] - 1
if max > n:
	print(-1)
	sys.exit(0)
flag = False
for i in range(m):
	if i + l[i] > n:
		flag = True
		break
if flag:
	print(-1)
	sys.exit(0)
for i in range(m - 2, -1, -1):
	if l[i] > 1:
		if l[i] - 1 + max <= n:
			max = max + l[i] - 1
			pre[i + 1] += l[i] - 1
		else:
			pre[i + 1] += n - max
			max = n
	if max == n:
		break
previous = 0
for i in range(m):
	previous = previous + pre[i]
	if pre[i] == 0:
		previous += 1
	print(previous, end=' ')
print()


from sys import stdin, stdout
(n, m) = [int(x) for x in stdin.readline().split()]
ops = [int(x) for x in stdin.readline().split()]
s = sum(ops)
if s < n:
	print(-1)
else:
	diff = s - n
	cur = 0
	out = []
	valid = True
	for x in ops:
		if cur + x > n:
			valid = False
			break
		out.append(str(cur + 1))
		ad = max(1, x - diff)
		diff -= x - ad
		cur += ad
	if valid:
		print(' '.join(out))
	else:
		print(-1)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import ceil, floor
from copy import *
from collections import deque, defaultdict
from collections import Counter as counter
from itertools import combinations
from itertools import permutations as permutate
from bisect import bisect_left as bl
from operator import *
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))
mod = 1000000007

def testcase(t):
	for p in range(t):
		solve()

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a

def prefix_sum(ar):
	return list(accumulate(ar))

def suffix_sum(ar):
	return list(accumulate(ar[::-1]))[::-1]

def N():
	return int(inp())
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]

def YES():
	print('YES')

def NO():
	print('NO')

def Yes():
	print('Yes')

def No():
	print('No')
from collections import defaultdict

def numberOfSetBits(i):
	i = i - (i >> 1 & 1431655765)
	i = (i & 858993459) + (i >> 2 & 858993459)
	return ((i + (i >> 4) & 252645135) * 16843009 & 4294967295) >> 24

class MergeFind:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n

	def find(self, a):
		to_update = []
		while a != self.parent[a]:
			to_update.append(a)
			a = self.parent[a]
		for b in to_update:
			self.parent[b] = a
		return self.parent[a]

	def merge(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return
		if self.size[a] < self.size[b]:
			(a, b) = (b, a)
		self.num_sets -= 1
		self.parent[b] = a
		self.size[a] += self.size[b]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

def lcm(a, b):
	return abs(a // gcd(a, b) * b)

def comb(n, r):
	if n < r:
		return 0
	else:
		return fac[n] * (finv[r] * finv[n - r] % mod) % mod

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def nextline():
	out('\n')

def arr1d(n, v):
	return [v] * n

def arr2d(n, m, v):
	return [[v] * m for _ in range(n)]

def arr3d(n, m, p, v):
	return [[[v] * p for _ in range(m)] for i in range(n)]

def solve():
	(n, m) = sep()
	l = lis()
	total = sum(l)
	if total < n:
		print(-1)
		return
	rem = total - n
	pos = 1
	ans = []
	for (i, x) in enumerate(l):
		ans += [pos]
		if pos + x > n + 1:
			print(-1)
			return
		saved = min(rem, x - 1)
		rem -= saved
		pos += x - saved
	print(*ans)
solve()


def main():
	import sys
	input = sys.stdin.readline
	(N, M) = map(int, input().split())
	L = list(map(int, input().split()))
	if sum(L) < N:
		print(-1)
		exit()
	ans = [0] * M
	left = N
	for i in range(M - 1, -1, -1):
		if left - L[i] >= i:
			ans[i] = left - L[i] + 1
			left -= L[i]
		else:
			if i + L[i] - 1 >= N:
				print(-1)
				exit()
			ans[i] = i + 1
			left = i
	print(*ans)
main()


(n, m) = map(int, input().split())
l = [int(x) for x in input().split()]
(s, res, p) = ([], [], 0)
s.append(l[-1])
for i in range(m - 2, -1, -1):
	s.append(s[m - i - 2] + l[i])
s.reverse()
if s[0] < n:
	print(-1)
else:
	for i in range(m):
		p = max(n - s[i] + 1, p + 1)
		if not 1 <= p <= n - l[i] + 1:
			p = 0
			break
		else:
			res.append(p)
	if p + l[-1] == n + 1:
		print(*res)
	else:
		print(-1)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
ls = sum(l)
ans = []
import sys
if ls < n or m - 1 + l[-1] > n:
	print(-1)
	sys.exit()
cut = []
remain = ls - n
for i in range(m):
	if l[i] - 1 < remain:
		cut.append(l[i] - 1)
		remain -= l[i] - 1
	else:
		cut.append(remain)
		remain = 0
l2 = [0] * m
for i in range(m):
	l2[i] = l[i] - cut[i]
now = 1
for i in range(m):
	ans.append(now)
	now += l2[i]
for i in range(m):
	if l[i] + ans[i] - 1 > n:
		print(-1)
		sys.exit()
print(*ans)


(n, m) = map(int, input().split())
blocks = [int(x) for x in input().split()]
b2 = [(blocks[i], i) for i in range(len(blocks))]
s = sum(blocks)
if s < n:
	print(-1)
else:
	p = [0] * len(b2)
	rem = s
	x = n
	i = 0
	br = 1
	f = 0
	while rem > x and i != n:
		if b2[i][0] + i > n:
			br = 0
			break
		rem -= b2[i][0]
		p[b2[i][1]] = i + 1
		x -= 1
		i += 1
	while rem > 0 and br:
		f = 1
		p[b2[i][1]] = n - rem + 1
		rem -= b2[i][0]
		i += 1
	if f:
		print(*p)
	else:
		print(-1)


(n, m) = map(int, input().split())
new = list(map(int, input().split()))
a = []
if sum(new) < n:
	print(-1)
	exit()
for i in range(m):
	if new[i] + i > n:
		print(-1)
		exit()
for i in range(m):
	a.append((new[i], i))
suff = [-1] * m
suff[-1] = a[-1][0]
for i in range(m - 2, -1, -1):
	suff[i] = suff[i + 1] + a[i][0]
ans = [i for i in range(1, m + 1)]
for i in range(m):
	ans[i] = max(ans[i], n - suff[i] + 1)
print(*ans)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
from itertools import permutations
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')
(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
s = sum(a)
if s < n:
	print(-1)
else:
	r = []
	diff = s - n
	curr = 0
	valid = True
	for i in range(m):
		r.append(curr + 1)
		curr += a[i]
		if curr > n:
			valid = False
		d = min(diff, a[i] - 1)
		curr -= d
		diff -= d
	if valid:
		print(*r)
	else:
		print(-1)


from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
(n, m) = mi()
a = li()
if m > n:
	print('-1')
	exit()
if sum(a) < n:
	print('-1')
	exit()
for i in range(m):
	if a[i] > n - i:
		print('-1')
		exit()
p = [0] * (m + 1)
p[m] = n
q = [0] * (m + 1)
for i in range(m - 1, -1, -1):
	p[i] = max(i, p[i + 1] - a[i])
	q[i] = p[i] + 1
q = q[:m]
print(*q)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
possible = 1
t = 0
for i in range(m):
	if l[i] + i > n:
		possible = 0
	t += l[i]
if t < n:
	possible = 0
if possible == 0:
	print(-1)
else:
	d = t - n
	s = [0] * m
	s[0] = 1
	for i in range(m - 1):
		if d == 0:
			s[i + 1] = s[i] + l[i]
		elif d >= l[i]:
			d -= l[i]
			d += 1
			s[i + 1] = s[i] + 1
		else:
			s[i + 1] = s[i] + l[i] - d
			d = 0
	print(*s)


(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
s = sum(a)
if s < n:
	print(-1)
else:
	r = []
	diff = s - n
	curr = 0
	valid = True
	for i in range(m):
		r.append(curr + 1)
		curr += a[i]
		if curr > n:
			valid = False
		d = min(diff, a[i] - 1)
		curr -= d
		diff -= d
	if valid:
		print(*r)
	else:
		print(-1)


R = lambda : map(int, input().split())
(n, m) = R()
a = list(R())

def solve(a, n, m):
	if m > n:
		print(-1)
	b = [0] * m
	t = 0
	for i in range(m - 1, -1, -1):
		t += a[i]
		b[i] = t
	b.append(0)
	ar = []
	cur = 0
	for i in range(m):
		if b[i] < n - cur:
			print(-1)
			return
		if a[i] > n - cur:
			print(-1)
			return
		ar.append(cur)
		cur += 1
		while b[i + 1] < n - cur:
			cur += 1
	print(*[x + 1 for x in ar])
	return
solve(a, n, m)


(n, m) = map(int, input().split())
l = [0] + list(map(int, input().split()))
for i in range(1, m + 1):
	if l[i] + i - 1 > n:
		print(-1)
		exit()
suffix_sum = [0] * (m + 2)
for i in range(m + 1)[::-1]:
	suffix_sum[i] = suffix_sum[i + 1] + l[i]
if suffix_sum[1] < n:
	print(-1)
	exit()
p = [0] * (m + 1)
for i in range(1, m + 1):
	p[i] = max(i, n - suffix_sum[i] + 1)
print(*p[1:])


import sys
(n, m) = map(int, input().split(' '))
ms = list(map(int, input().split(' ')))
total = sum(ms)
if total < n:
	print(-1)
	sys.exit(0)
start = 1
s = [i for i in range(1, m + 1)]
mi = m - 1
needr = n
shift = 0
while mi >= 0:
	s[mi] -= shift
	if s[mi] + ms[mi] - 1 > n or s[mi] <= 0:
		print(-1)
		sys.exit(0)
	if s[mi] + ms[mi] - 1 < needr:
		sh = needr - (s[mi] + ms[mi] - 1)
		s[mi] += sh
	needr = min(needr, s[mi] - 1)
	mi -= 1
print(' '.join((str(x) for x in s)))


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

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

def sapin():
	return [int(x) for x in input()]
t = 1
for _ in range(t):
	(n, m) = mapin()
	l = [int(x) for x in input().split()]
	fl = 1
	for i in range(m):
		if l[i] + i > n:
			fl = 0
			print(-1)
			break
	if fl:
		s = [0] * (m + 1)
		for i in range(m - 1, -1, -1):
			s[i] = s[i + 1] + l[i]
		if s[0] < n:
			fl = 0
			print(-1)
			break
		if fl:
			fi = []
			for i in range(m):
				fi.append(max(i + 1, n - s[i] + 1))
			print(*fi)


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
A = list(map(int, input().split()))
if sum(A) < n:
	print(-1)
else:
	ANS = [i for i in range(m)]
	MCOLORED = 0
	for i in range(m):
		if i + A[i] > n:
			print(-1)
			sys.exit()
		MCOLORED = max(MCOLORED, i + A[i])
	MNC = n - 1
	ind = m - 1
	while ANS[ind] + A[ind] - 1 < MNC:
		x = MNC - A[ind] + 1
		if ind != 0 and ANS[ind - 1] >= x:
			print(-1)
			sys.exit()
		ANS[ind] = x
		MNC = x - 1
		ind -= 1
	ANS2 = [a + 1 for a in ANS]
	print(*ANS2)


import sys
input = sys.stdin.readline
from sys import stdin, stdout

def main():
	(n, m) = [int(s) for s in input().split()]
	l = [int(s) for s in input().split()]
	sums = [0] * m
	sums[0] = l[0]
	for i in range(1, m):
		sums[i] = sums[i - 1] + l[i]
	ww = 0
	for i in range(m):
		ww = max(ww, i + l[i])
	if max(ww, m + l[-1] - 1) > n:
		print(-1)
	elif sums[-1] < n:
		print(-1)
	elif m == 1:
		print(1)
	else:
		ans = [0] * m
		w = m + l[-1] - 1
		ans[-1] = n - l[-1] + 1
		j = m - 2
		while w + l[j] - 1 < n:
			w += l[j] - 1
			ans[j] = ans[j + 1] - l[j]
			j -= 1
		if j >= 0:
			for i in range(j + 1):
				ans[i] = i + 1
		print(*ans)
main()


line = input().split()
n = int(line[0])
m = int(line[1])
line = [int(x) for x in input().split()]
impossible = False
total_spaces = 0
for i in range(m):
	curr = line[i]
	if n - curr < i:
		impossible = True
		break
	total_spaces += curr
if impossible or total_spaces < n:
	print(-1)
else:
	index = 0
	remaining_slots_to_retrocede = total_spaces - n
	ans = []
	for i in range(m):
		ans.append(index)
		index += line[i]
		max_sots_to_retrocede = line[i] - 1
		index -= min(max_sots_to_retrocede, remaining_slots_to_retrocede)
		remaining_slots_to_retrocede -= min(max_sots_to_retrocede, remaining_slots_to_retrocede)
	for starting_point in ans:
		print(starting_point + 1, end=' ')
	print()


temp = input().split()
n = int(temp[0])
m = int(temp[1])
l = input().split()
for i in range(m):
	l[i] = int(l[i])
valid = True
total = 0
for i in range(m):
	if l[i] + i > n:
		valid = False
	total += l[i]
if total < n:
	valid = False
if valid:
	done = [x + 1 for x in range(m)]
	final = m - 1
	unfilled = n
	last = m - 1 + l[m - 1]
	while last < unfilled:
		done[final] = unfilled - l[final] + 1
		unfilled = unfilled - l[final]
		final -= 1
		last = final + l[final]
	print(done[0], end='')
	for i in range(1, len(done)):
		print(' ' + str(done[i]), end='')
else:
	print(-1)


(N, M) = input().split(' ')
(N, M) = (int(N), int(M))
L = input().split(' ')
L = list((int(x) for x in L))

def answer(N, M, L):
	offsets = [0]
	for i in range(M - 1):
		offsets += [1]
	overhang = 0
	for ii in range(M - 1):
		i = M - 1 - ii
		left_edge = i + 1
		right_edge = left_edge + L[i] - 1 + overhang
		if right_edge > N:
			return '-1'
		max_right_edge = right_edge + L[i - 1] - 1
		if max_right_edge > N:
			max_right_edge = N
		offsets[i] += max_right_edge - right_edge
		parent_right_edge = i + L[i - 1] - 1
		overhang = max(0, max_right_edge - parent_right_edge)
	if L[0] + overhang < N:
		return '-1'
	pos = 1
	ret = [1]
	for o in offsets[1:]:
		pos += o
		ret += [pos]
	return ' '.join((str(r) for r in ret))
print(answer(N, M, L))


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
total = sum(l)
if total < n:
	print(-1)
	exit()
rem = total - n
pos = 1
ans = []
for (i, x) in enumerate(l):
	ans += [pos]
	if pos + x > n + 1:
		print(-1)
		exit()
	saved = min(rem, x - 1)
	rem -= saved
	pos += x - saved
print(*ans)


import sys
import itertools
input = sys.stdin.readline

def main():
	(N, M) = [int(x) for x in input().split()]
	L = [int(x) for x in input().split()]
	if sum(L) < N:
		print(-1)
		return
	ruiseki = list(itertools.accumulate(L[::-1]))
	ans = []
	for (i, l) in enumerate(L):
		if i == 0:
			ans.append(1)
			continue
		elif i == M - 1:
			x = N - ruiseki[-i - 1] + 1
			ans.append(x)
			if ans[i] - ans[i - 1] > L[i - 1]:
				print(-1)
				return
			if ans[i] <= ans[i - 1]:
				print(-1)
				return
		else:
			x = N - ruiseki[-i - 1] + 1
			x = max(ans[i - 1] + 1, x)
			ans.append(x)
			if N + 1 - x < l:
				print(-1)
				return
			if ans[i] - ans[i - 1] > L[i - 1]:
				print(-1)
				return
	print(*ans)
main()