Return the index of the added element when inserting.