Replace all the elements of a given array with the closest greater element to its right. Elements that do not have a greater element on their right should be replaced by -1.

Programming