Solution for sequence