Deriving the Madelung Rule on the Tech Tree