Consider sequence ai, for i = 1, ... , n, the sum (modulo n) of the first i elements of the original sequence.