By (nums[i]-1) % n, we can calculate the original number in the array.

For example, [4, 3, 2, 7, 8, 2, 3, 1]

if i == 1, nums[i] = 3, nums[i]-1 = 2, we will visit the first 2,

after visit this 2 will become 10, since n is 8

if i == 2, nums[i] = 10, nums[i]-1 = 9, which is wrong

Thus we need 10 % 8 = 2 to calculate the original number to get the index.

if i ==2, (nums[i]-1) % n = 1, we can visit correctly