Deuteronomy 21:16

21:16 In the day he divides his inheritance he must not appoint as firstborn the son of the favorite wife in place of the other wife’s son who is actually the firstborn.