Potential energy is the energy possessed by an object due to its position relative to a reference line. Potential energy is given as 
PE = mgh 
where m = mass of the object 
g = acceleration due to gravity
h = height from the reference line.
from the formula , we see that potential energy is directly proportional to the height. hence greater the height, larger will be the potential energy.
hence the potential energy is greatest when 
when it reaches the highest point on the ramp