There is a river of width $n$. The left bank of the river is cell $0$ and the right bank is cell $n + 1$ (more formally, the river can be represented as a sequence of $n + 2$ cells numbered from $0$ to $n + 1$). There are also $m$ wooden platforms on a river, the $i$-th platform has length $c_i$ (so the $i$-th platform takes $c_i$ consecutive cells of the river). It is guaranteed that the sum of lengths of platforms does not exceed $n$.

You are standing at $0$ and want to reach $n+1$ somehow. If you are standing at the position $x$, you can jump to any position in the range $[x + 1; x + d]$. However you don't really like the water so you can jump only to such cells that belong to some wooden platform. For example, if $d=1$, you can jump only to the next position (if it belongs to the wooden platform). You can assume that cells $0$ and $n+1$ belong to wooden platforms.

You want to know if it is possible to reach $n+1$ from $0$ if you can move any platform to the left or to the right arbitrary number of times (possibly, zero) as long as they do not intersect each other (but two platforms can touch each other). It also means that you cannot change the relative order of platforms.

Note that you should move platforms until you start jumping (in other words, you first move the platforms and then start jumping).

For example, if $n=7$, $m=3$, $d=2$ and $c = [1, 2, 1]$, then one of the ways to reach $8$ from $0$ is follow:

 [Image] The first example: $n=7$. 


-----Input-----

The first line of the input contains three integers $n$, $m$ and $d$ ($1 \le n, m, d \le 1000, m \le n$) — the width of the river, the number of platforms and the maximum distance of your jump, correspondingly.

The second line of the input contains $m$ integers $c_1, c_2, \dots, c_m$ ($1 \le c_i \le n, \sum\limits_{i=1}^{m} c_i \le n$), where $c_i$ is the length of the $i$-th platform.


-----Output-----

If it is impossible to reach $n+1$ from $0$, print NO in the first line. Otherwise, print YES in the first line and the array $a$ of length $n$ in the second line — the sequence of river cells (excluding cell $0$ and cell $n + 1$).

If the cell $i$ does not belong to any platform, $a_i$ should be $0$. Otherwise, it should be equal to the index of the platform ($1$-indexed, platforms are numbered from $1$ to $m$ in order of input) to which the cell $i$ belongs.

Note that all $a_i$ equal to $1$ should form a contiguous subsegment of the array $a$ of length $c_1$, all $a_i$ equal to $2$ should form a contiguous subsegment of the array $a$ of length $c_2$, ..., all $a_i$ equal to $m$ should form a contiguous subsegment of the array $a$ of length $c_m$. The leftmost position of $2$ in $a$ should be greater than the rightmost position of $1$, the leftmost position of $3$ in $a$ should be greater than the rightmost position of $2$, ..., the leftmost position of $m$ in $a$ should be greater than the rightmost position of $m-1$.

See example outputs for better understanding.


-----Examples-----
Input
7 3 2
1 2 1

Output
YES
0 1 0 2 2 0 3 

Input
10 1 11
1

Output
YES
0 0 0 0 0 0 0 0 0 1 

Input
10 1 5
2

Output
YES
0 0 0 0 1 1 0 0 0 0 



-----Note-----

Consider the first example: the answer is $[0, 1, 0, 2, 2, 0, 3]$. The sequence of jumps you perform is $0 \rightarrow 2 \rightarrow 4 \rightarrow 5 \rightarrow 7 \rightarrow 8$.

Consider the second example: it does not matter how to place the platform because you always can jump from $0$ to $11$.

Consider the third example: the answer is $[0, 0, 0, 0, 1, 1, 0, 0, 0, 0]$. The sequence of jumps you perform is $0 \rightarrow 5 \rightarrow 6 \rightarrow 11$.

Difficulty: introductory

Starter code:

Solutions:

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,M,d = inpl()
CC = inpl()

if sum(CC) + (d-1)*(M+1) < N:
    print("NO")
else:
    x = 0
    ans = [0]*(d-1)
    i = 0
    for i in range(M):
        ans += [i+1] * CC[i]
        ans += [0] * (d-1)

    L = len(ans) - N
    ans2 = []
    for a in ans:
        if a == 0 and L > 0:
            L -= 1
        else:
            ans2.append(a)

    print("YES")
    print(" ".join(map(str,ans2)))


import sys
n, m, d = list(map(int, input().split()))
c = list(map(int, input().split()))

cur = 0
for p in range(m):
    cur += d
    cur += c[p] - 1
if cur < n + 1 - d:
    print('NO')
    return
res = [0] * n
cur = n - 1
for p in range(m - 1, -1, -1):
    for j in range(c[p]):
        res[cur] = p + 1
        cur -= 1
cur = 0
while cur < n + 1:
    cur += d
    if cur >= n + 1:
        break
    if res[cur - 1] == 0:
        idx = -1
        for j in range(cur, len(res)):
            if res[j] != 0:
                idx = j
                break
        cnt = 1
        for j in range(idx + 1, len(res)):
            if res[j] == res[idx]:
                cnt += 1
        num = res[idx]
        for j in range(cnt):
            res[cur + j - 1] = num
            res[idx + j] = 0
    while cur < len(res) and res[cur] > 0:
        cur += 1
print("YES")
print(' '.join(str(x) for x in res))
        


arr = [int (i) for i in filter(None, input().split(" "))]
s = arr[0]
k = arr[1]
mx = arr[2]
arr = [int (i) for i in filter(None, input().split(" "))]
sum = 0
for i in range(k):
    sum+=arr[i]
sum+=(mx-1)*(k+1)
if sum<s:
    wer = "NO"
    print(wer)
else:
    wer = "YES"
    ans = [0]*(mx-1)
    for i in range(k):
        ans+=[i+1]*arr[i]
        ans+=[0]*(mx-1)
    max = len(ans)
    for i in range(len(ans)):
        if max<=s:
            break
        else:
            if ans[i] ==0:
                ans[i]=-1
                max-=1
    answer = []
    for i in range(len(ans)):
        if ans[i]!=-1:
            answer.append(ans[i])
    print(wer)
    for i in range(len(answer)):
        print(answer[i], end=' ')




n,m,d=map(int,input().split())
c=list(map(int,input().split()))
ans=[]
s=sum(c)
ind=[]
j=-1
for i in range(len(c)):
    v=min(j+d,n-s)
    ind.append(v)
    j=v+c[i]-1
    s-=c[i]
ans=[]
if n-j>d:
    print("NO")
    return
i=0
j=0
v=1
while i<n:
    if j<len(ind) and i==ind[j]:
        for l in range(c[j]):
            ans.append(v)
        v+=1
        i+=c[j]
        j+=1
    else:
        i+=1
        ans.append(0)
print("YES")
print(*ans)

n,m,d = list(map(int, input().split()))
plank = list(map(int, input().split()))
summ = sum(plank)
j = 0
ans = [0]*n
curr = -1
i = 0
flag = 0
while(i<n):
    if(summ == n-i): # use all planks
        if(j==m):
            print("NO")
            flag = 1
            break
        for _ in range(plank[j]):
            ans[i] = j+1
            i = i + 1
        summ = summ - plank[j]
        j = j + 1
        curr = i - 1
    elif(i-curr==d):
        if(j==m):
            flag = 1
            print("NO")
            break
        for _ in range(plank[j]):
            ans[i] = j+1
            i = i + 1
        summ = summ - plank[j]
        j = j + 1
        curr = i - 1
    else:
        i = i + 1
if(flag==0):
    print("YES")
    print(*ans)


import sys
input=sys.stdin.readline

n,m,d=list(map(int,input().split())) 
arr=list(map(int,input().split())) 
tot=sum(arr)
res=[0]*n
gap=1
ptr=0
j=0
bool1=True
while(j<n):
	if(gap<d and n-(j+1)>=tot):
		j+=1
		gap+=1
		continue
	else:
		if(ptr<m):
			for k in range(j,j+arr[ptr]):
				res[k]=(ptr+1)
			gap=1
			tot-=arr[ptr]
			j+=arr[ptr]
			# print(j-1)
			ptr+=1
		else:
			j+=1
			bool1=False
	# print(j)
# print(res,bool1)
if(bool1==False):
	print("NO")	
else:
	print("YES")
	s=""
	for i in res:
		s=s+str(i)+" "
	s=s[:-1]
	print(s)




n,m,d=[int(x) for x in input().split(' ')]
list1=[int(x) for x in input().split(' ')]
x=(m+1)*(d-1)+sum(list1)
list2=[]
a=0
b=0
if x < n:
    print('NO')
else:
    print('YES')
    n0=n-sum(list1)
    while b <= m:
        if a == 0:
            if n0 >= d-1:
                list2.extend(['0']*(d-1))
                a+=1
                b+=1
                n0-=(d-1)
            elif 0 < n0 < (d-1):
                list2.extend(['0']*n0)
                a+=1
                b+=1
                n0=0
            else:
                a+=1
                b+=1
        else:
            list2.extend([str(b)]*list1[b-1])
            a-=1
    print(' '.join(list2)) 
        
    


data = (list(map(int, input().split())))

c = (list(map(int, input().split())))

csum = sum(c)

if (data[2] == 0):
    print("NO")
else:
    if (csum+(data[2]-1)*(data[1]+1)>= data[0]):
        print("YES")
        
        empt = data[0] - csum
        
        allempt = 0
        
        sol = []
        
        for i in range(data[1]):
            
            if(allempt < empt):
                for z in range(data[2]-1):
                    if(allempt >= empt):
                        break
                    sol.append(0)
                    allempt+=1
                    
            for j in range(c[i]):
                sol.append((i+1))
            
            q = data[0] - len(sol)
            
        if (q != 0):
            for i in range(q):
                sol.append(0)
            
        print (*sol)
        
    else:
        print("NO")

n,m,d = list(map(int, input().split()))
c = list(map(int, input().split()))
sumc = 0
for elem in c:
    sumc += elem
if sumc + (m+1)*(d-1) < n:
    print('NO')
else:
    print('YES')
    ans = []
    x = n - sumc
    for i in range(m):
        if x > d-1:
            for j in range(d-1):
                ans.append(0)
            for j in range(c[i]):
                ans.append(i+1)
            x -= (d-1)
        elif x > 0:
            for j in range(x):
                ans.append(0)
            for j in range(c[i]):
                ans.append(i+1)
            x = 0
        else:
            for j in range(c[i]):
                ans.append(i+1)
    for j in range(x):
        ans.append(0)
    print(*ans)



import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return list(map(int,minp().split()))

def solve():
	n, m, d = mints()

	a = list(mints())
	b = [0]*m
	s = sum(a)
	p = 0
	for i in range(m):
		b[i] = p + d
		p = p + d + a[i] - 1
	if b[-1] + a[-1] - 1 + d < n + 1:
		print("NO")
		return
	p = n + 1
	c = [0]*n
	for i in range(m-1,-1,-1):
		if b[i] + a[i] - 1 >= p:
			b[i] = p - a[i]
		p = b[i]
		#print(i, b[i], a[i], b[i]+a[i])
		for j in range(b[i], b[i] + a[i]):
			c[j-1] = i + 1
	print("YES")
	print(*c)

solve()


line = input().split()

n = int(line[0])
m = int(line[1])
d = int(line[2])

line = input().split()

c = [int(x) for x in line]

# print(c[0])

if sum(c) + (len(c) + 1) * (d - 1) < n:
	print('NO')

else:
	cnt = n - sum(c)

	ans = []

	cnt2 = 0

	while cnt != 0:

		# print('counter is ' + str(cnt))

		for i in range(d-1):

			if cnt == 0:
				break

			ans.append(0)
			cnt -= 1

		if cnt2 >= len(c):
			break

		for i in range(c[cnt2]):
			ans.append(cnt2+1)

		cnt2 += 1

	while cnt2 != m:
		for i in range(c[cnt2]):
			ans.append(cnt2+1)

		cnt2 += 1

	print('YES')

	for ch in ans:
		print(str(ch), end=' ')

	print()

def gcd(a, b):
    if a == 0:
        return b
    else:
        return gcd(b % a, a)
 
 
n, m, d = list(map(int, input().split()))
 
a = list(map(int, input().split()))
j = 0
p = m - 1
k = [0] * n
for i in range(n - 1, -1, -1):
    k[i] = p + 1
    j += 1
    if a[p] <= j:
        j = 0
        p -= 1
        if p == -1:
            break
    
z = 0

last = -1
for i in range(n):
    if k[i] == 1:
        last = i
    if i - last >= d and k[i] == 0:
        #print(i, last, k, z, a[z] + i, a[z])
        for j in range(0, n):
            if k[j] == z + 1:
                k[j] = 0
        for j in range(i, a[z] + i):
            k[j] = z + 1
            last = j
        z += 1
        #print(z, k)
        if z == m and n - last > d:
            print('NO')
            return
if d > n:
    print('YES')
    print('1 ' * a[z] + '0 ' * (n - a[z]))
    return
print('YES')
print(*k)
           
            
            


import sys
# input = sys.stdin.buffer.readline
input = sys.stdin.readline


n,m,d = list(map(int, input().split()))
li = list(map(int, input().split()))
x=0
l=0
maxx = sum(li)+(d-1)*(m+1)

off = maxx - n
# print(maxx,off)
outlist=[]
for i in range(m):
    # print(off,d)
    if (off)>=d:
        
        off-=(d-1)
    else:
        outlist.extend([0]*(d-off-1))
        off=0
    outlist.extend([i+1]*li[i])

if (off)>d:
        off-=(d-1)
else:
    outlist.extend([0]*(d-off-1))
    off=0

if maxx>=n:
    print("YES")
    print(" ".join([str(a) for a in outlist]))
else:
    print("NO")
# print(l)


n,m,d = map(int,input().split())
c = list(map(int,input().split()))
sc = sum(c)
if sc + (len(c)+ 1) * (d - 1) < n:
    print("NO")
else:
    print("YES")
    ko = n - sc
    for i in range(m):
        if ko != 0:
            if ko >= d - 1:
                print("0 " * (d -1 ), end = "")
                ko -= d -1
            else:
                print("0 " * (ko ), end = "")
                ko = 0
        print((str(i + 1) + " ") * c[i], end = "")
    print("0 " * (ko ), end = "")


n, m, d = map(int, input().split())
c = list(map(int, input().split()))
sum_c = sum(c)
tmp_ans = sum_c + (m+1)*(d-1)
if tmp_ans < n:
    print("NO")
    return
nokori = tmp_ans - n

ans = [0] * n
j = 1
for i in range(m):
    j -= 1
    if nokori >= d - 1:
        nokori -= d - 1
    else:
        j += (d - 1 - nokori)
        nokori = 0
    for _ in range(c[i]):
        ans[i+j] = i+1
        j += 1
print("YES")
print(*ans)

n, m, d = list(map(int, input().split()))
c = list(map(int, input().split()))
r = sum(c)
cur = 0
ci = 0
mmap = [0] * n
while cur < n+1 and ci < len(c):
    #print("pi =min ", cur + d," ",  n - r + 1)

    pi = min(cur + d, n - r + 1)
    #print("pi = ", pi)
    for j in range(pi, pi+c[ci]):
        mmap[j-1] = ci+1
    cur = pi + c[ci]-1
    r -= c[ci]
    ci += 1
    
if cur + d >= n+1:
    print("YES")
    print(" ".join(map(str, mmap)))
else:
    print("NO")


import sys


n, m, d = list(map(int, input().split()))
M = list(map(int, sys.stdin.readline().split())) 
sumM = sum(M)
A = [0] * n
posit = -1
for platf in range(m):
    for ii in range(posit + min(d, n - sumM - posit), posit + min(d, n - sumM - posit) + M[platf]):
        A[ii] = platf + 1
    posit = ii
    sumM -= M[platf]    
if n - posit > d:
    print("NO")
else:
    print("YES")
    print(*A)


n, m, d = map(int, input().split())
p = list(map(int, input().split()))

positions = [0] * len(p)
positions[-1] = n + 1 - p[-1]
for i in reversed(range(len(p)-1)):
    positions[i] = positions[i+1] - p[i]

def feasible(p, positions, d):
    if positions[0] > d:
        return False
    for i in range(1, len(p)):
        if positions[i] - (positions[i-1] + p[i-1] - 1) > d:
            return False
    if n+1 - (positions[-1] + p[-1] - 1) > d:
        return False
    return True

g = [0] * m
g[0] = d
for i in range(1, m):
    g[i] = g[i-1] + p[i-1] - 1 + d

i = 0
while not feasible(p, positions, d) and i < len(p):
    positions[i] = g[i]
    i += 1

if feasible(p, positions, d):
    print("YES")
    board = [0] * n
    for i in range(m):
        for j in range(p[i]):
            board[positions[i]-1+j] = i+1
    for e in board:
        print(e, end=' ')
    print()
else:
    print("NO")

def move(rightmost, d, seq, current):
	plankno = seq[rightmost]
	# print(*seq)
	# while seq[rightmost] == plankno:
	moving = rightmost

	rem = rightmost-current-d
	rightmost += 1
	# print(rem)
	for i in range(rem):
		temp = seq[moving]
		seq[moving] = seq[moving-1]
		seq[moving-1] = temp
		moving -= 1


	# print(*seq, rightmost, moving)

	while rightmost != len(seq) and seq[rightmost] == plankno:
		seq[rightmost] = 0
		rightmost += 1

		seq[moving+1] = plankno
		moving += 1

	# print(*seq, moving, rightmost)
	return moving, rightmost


		# break




n, m, d = list(map(int, input().split()))
arr = [int(j) for j in input().split()]

planks = []
for i in range(m):
	planks += [i+1]*arr[i]

rem = [0]*(n-len(planks))
seq = rem + planks
# print(seq)
# print(rem, planks)

rightmost = n-1
while seq[rightmost] != 0 and rightmost != -1:
	rightmost -= 1

rightmost += 1
current = -1
# print(rightmost, current)

for i in range(m):
	if rightmost - current <= d:
		current = n-1
		break
	else:
		current, rightmost = move(rightmost, d, seq, current)


# print(n-current)
if n-current > d:
	print("NO")
else:
	print("YES")
	print(*seq)





'''
https://codeforces.com/contest/1256/problem/C
'''


n, m, d = list(map(int, input().split()))
cs = list(map(int, input().split()))


ls = [0] * m
ls[m - 1] = cs[m - 1]
for i in range(m - 1):
    ls[m - i - 2] = ls[m - i - 1] + cs[m - i - 2]


if ls[0] + (d - 1) * (m + 1) < n:
    print('NO')
else:
    ns = [0] * n
    ci = 0
    jump = 1
    i = 0
    while i < n and ci < m:
        # print(i)
        # print(n - i)
        if ls[ci] < n - i:
            if jump < d:
                jump += 1
                ns[i] = 0
            else:
                for i in range(i, i + cs[ci]):
                    ns[i] = ci + 1
                    jump = 1
                ci += 1
        else:
            # print(list(range(i, i + cs[ci])))
            for i in range(i, i + cs[ci]):
                ns[i] = ci + 1
                jump = 1
            ci += 1
        i += 1
    print('YES')
    print(' '.join(list(map(str, ns))))


from itertools import accumulate

n, m, dmax = list(map(int, input().split()))
c = list(map(int, input().split()))

if sum(c) - m + dmax * (m+1) < n+1:
    print('NO')
    return
else:
    print('YES')

d = (n - sum(c)) // (m+1)
major_num = (n - sum(c)) - d * (m+1)

ans = []
k = 1
for i in range(major_num):
    ans.extend([0] * (d + 1))
    ans.extend([k] * c[k-1])
    k += 1
for i in range(m + 1 - major_num - 1):
    ans.extend([0] * d)
    ans.extend(([k] * c[k-1]))
    k += 1
ans.extend(([0] * d))
print(*ans)


n, m, d = list(map(int, input().split()))

lengths = list(map(int, input().split()))
poses = [n + 1] * (m + 1)
index = m - 1
while index >= 0:
    poses[index] = poses[index + 1] - lengths[index]
    index -= 1

#print(poses)

cur = 0
ind = 0
result = True
while cur < n + 1:
    if cur + d >= n + 1:
        break
    if ind == m:
        result = False
        break
    if cur + d <= poses[ind]:
        poses[ind] = cur + d
        cur = cur + d + lengths[ind] - 1
        ind += 1
    else:
        cur = cur + d

if result:
    print("YES")
    poses.append(0)
    lengths.append(0)
    lengths.append(1)
    res = []
    for ind, it in enumerate(poses[:-1]):
        for _ in range(it - poses[ind - 1] - lengths[ind - 1]):
            res.append('0')
        for _ in range(lengths[ind]):
            res.append(str(ind + 1))
    print(" ".join(res))
else:
    print("NO")


import sys
input = sys.stdin.readline

def main():
    n, m, d = [int(x) for x in input().split()]
    C = [int(x) for x in input().split()]

    current = -1
    ans = [0] * (1000 * 1000)
    for i, c in enumerate(C):
        current += d - 1
        for j in range(c):
            current += 1
            ans[current] = i + 1

    if current + d < n:
        print("NO")
    else:
        print("YES")
        amari = current - (n - 1)
        count = 0
        for a in ans:
            if a == 0 and amari > 0:
                amari -= 1
                continue
            count += 1
            print(a, end=" ")
            if count == n:
                break
        print("")









def __starting_point():
    main()



__starting_point()

n, m, d = map(int, input().split())
c = list(map(int, input().split()))

boards = [None]*(m+1)
boards[-1] = [n+1, n+1]
for i in range(m-1, -1, -1):
    boards[i] = [boards[i+1][0]-c[i], boards[i+1][0]-1]

pos = 0
for i in range(m+1):
    if pos + 1 == boards[i][0]:
        pos = boards[i][1]
        continue
    if boards[i][0] <= pos + d <= n+1:
        if pos + d <= boards[i][1]:
            pos = boards[i][1]
        continue
    diff = boards[i][0] - (pos+d)
    boards[i][0] -= diff
    boards[i][1] -= diff
    pos = boards[i][1]

if pos < n+1:
    print('NO')
    return
else:
    ans = [0]*(n+1)
    for i in range(m):
        for j in range(boards[i][0], boards[i][1]+1):
            ans[j] = i+1

    print('YES')
    print(*ans[1:])

n, m, d = list(map(int, input().split()))

lengths = list(map(int, input().split()))
poses = [n + 1] * (m + 1)
index = m - 1
while index >= 0:
    poses[index] = poses[index + 1] - lengths[index]
    index -= 1

#print(poses)

cur = 0
ind = 0
result = True
while cur < n + 1:
    if cur + d >= n + 1:
        break
    if ind == m:
        result = False
        break
    if cur + d <= poses[ind]:
        poses[ind] = cur + d
        cur = cur + d + lengths[ind] - 1
        ind += 1
    else:
        break

if result:
    print("YES")
    poses.append(0)
    lengths.append(0)
    lengths.append(1)
    res = []
    for ind, it in enumerate(poses[:-1]):
        for _ in range(it - poses[ind - 1] - lengths[ind - 1]):
            res.append('0')
        for _ in range(lengths[ind]):
            res.append(str(ind + 1))
    print(" ".join(res))
else:
    print("NO")