Go to the levitical priests and to the head judge in office at that time and look into things there. They will announce to you the correct ruling.
You must then act according to the ruling they announced to you from that location, the one the LORD selects. You must follow very carefully everything they instruct you to do.
Act precisely according to the instruction they give you and the ruling they announce to you. Don't deviate even a bit from the word they announce.
And whoever acts rashly by not listening to the priest who is in office serving the LORD your God or to the head judge will die. Remove such evil from Israel!
References for Deuteronomy 17:12
All the people will hear about this and be afraid. They won't act arrogantly anymore.
Once you have entered the land the LORD your God is giving you and you have taken possession of it and settled down in it, you might say: "Let's appoint a king over us, as all our neighboring nations have done."
References for Deuteronomy 17:14
You can indeed appoint over you a king that the LORD your God selects. You can appoint over you a king who is one of your fellow Israelites. You are not allowed to appoint over you a foreigner who is not one of your fellow Israelites.
That granted, the king must not acquire too many horses, and he must not return the people to Egypt in order to acquire more horses, because the LORD told you: "You will never go back by that road again."
The king must not take numerous wives so that his heart doesn't go astray. Nor can the king acquire too much silver and gold.
Instead, when he sits on his royal throne, he himself must write a copy of this Instruction on a scroll in the presence of the levitical priests.
That Instruction must remain with him, and he must read in it every day of his life so that he learns to revere the LORD his God by keeping all the words of this Instruction and these regulations, by doing them,