function rl()
   r = {}
   for word in io.read():gmatch("%S+") do
      table.insert(r, tonumber(word))
   end
   return r
end

function ru()
   return unpack(rl())
end

a = ru()

print(a + a*a + a*a*a)
