If right sensor have more distance than other two then it moves right. If all the sensors have less than max range then it checks which is greater in them.
I will provide arduino code as well, don't worry. Follow this algorithm clearly, while writing your arduino code.
This is the algorithm when you use three ultrasonic sensors.