What Would Happen If the Prime Minister Lost Their Seat?

Britain’s unwritten constitution assumes the incumbent Prime Minister gets the first chance to form a government. But what happens if that Prime Minister has been personally ejected by voters in their constituency?