module practiceA
  sub Main(ByVal args() as String)
    dim n,k,m as integer
    dim res as integer
    dim i as integer
    dim diff as integer
    dim arr(100) as string
    arr=Split(Console.ReadLine())
    n=arr(0):k=arr(1):m=arr(2)
    arr=Split(Console.ReadLine())
    for i = 0 to n-2
    	res = arr(i)
    	diff = diff + m - res
  	next
  	res = m+diff
  	if  res < 0 then res = 0
  	if  res > k then res = -1
    Console.Write(res)
  end sub
end module