def cmp(a,b,f):
if (f>0):
return a>b
else:
return a<b
def partSort(arr,ibeg,iend,f):
if (iend>ibeg):
sep=arr[(ibeg+iend)//2]
i=ibeg
j=iend
while(True):
while(cmp(sep,arr[i],f)): # arr[i]<sep):
i+=1
while(cmp(arr[j],sep,f)): # arr[j]>sep):
j-=1
if (i<=j):
arr[i],arr[j]=arr[j],arr[i]
i+=1
j-=1
if (i>j):
break
partSort(arr,ibeg,j,f)
partSort(arr,i,iend,f)
n = int(input())
arr = list(map(int, input().split(maxsplit = n)))
ibeg, iend, f = map(int, input().split(maxsplit = 3))
partSort(arr,ibeg-1,iend-1,f)
print(str(arr))
ZGVmIGNtcChhLGIsZik6CglpZiAoZj4wKToKCQlyZXR1cm4gYT5iCgllbHNlOgoJCXJldHVybiBhPGIKCQpkZWYgcGFydFNvcnQoYXJyLGliZWcsaWVuZCxmKToKCWlmIChpZW5kPmliZWcpOgoJCXNlcD1hcnJbKGliZWcraWVuZCkvLzJdCgkJaT1pYmVnCgkJaj1pZW5kCgkJd2hpbGUoVHJ1ZSk6CgkJCXdoaWxlKGNtcChzZXAsYXJyW2ldLGYpKTogIyBhcnJbaV08c2VwKToKCQkJCWkrPTEKCQkJd2hpbGUoY21wKGFycltqXSxzZXAsZikpOiAjIGFycltqXT5zZXApOgoJCQkJai09MQoJCQlpZiAoaTw9aik6CgkJCQlhcnJbaV0sYXJyW2pdPWFycltqXSxhcnJbaV0KCQkJCWkrPTEKCQkJCWotPTEKCQkJaWYgKGk+aik6CgkJCQlicmVhawoJCXBhcnRTb3J0KGFycixpYmVnLGosZikKCQlwYXJ0U29ydChhcnIsaSxpZW5kLGYpCgpuID0gaW50KGlucHV0KCkpCmFyciA9IGxpc3QobWFwKGludCwgaW5wdXQoKS5zcGxpdChtYXhzcGxpdCA9IG4pKSkKaWJlZywgaWVuZCwgZiA9IG1hcChpbnQsIGlucHV0KCkuc3BsaXQobWF4c3BsaXQgPSAzKSkKcGFydFNvcnQoYXJyLGliZWctMSxpZW5kLTEsZikKcHJpbnQoc3RyKGFycikpCgo=