WHo elected the king?