Deuteronomy 21:15-16

LEB(i) 15 "If a man has two wives, and the one is loved and the other one is disliked and the one loved and the one that is disliked have borne for him sons, if it happens that the firstborn son belongs to the one that is disliked,* 16 nevertheless it will be the case that* on the day of bestowing his inheritance upon his sons, he will not be allowed to treat as the firstborn son the son of the beloved wife in preference to* the son of the disliked wife, who is the firstborn son.