Genetic response to the sequence of two environments