In the UK we dont elect the Prime Minister. We elect local MPs who represent a party of some kind. The group of MPs with the largest party or coalition of parties become the government with one of their number being Prime Minister. If the nominal head of a political party that won the general election didnt win his seat, then a new leader would need to be found. This I suppose is why the parties put their leaders in what are considered safe seats. And the new Prime Minister most certainly was elected - he will have to be chosen from the current crop of elected MPs.