"""
Given an array arr, 
replace every element in that array with the greatest 
element among the elements to its right, and replace 
the last element with -1.

After doing so, return the array.
"""

arr = [17,18,5,4,6,1]
#print(arr[-1])

for i in range(len(arr)-1):
    if arr[i] < max(arr[i+1:]):
        arr[i] = max(arr[i+1:])
arr[-1] = -1


print(arr)