Traverse the array
for i in range ( len ( arr ) ) : NEW_LINE INDENT temp = arr [ i ] NEW_LINE if i == len ( arr ) - 1 : NEW_LINE INDENT next = lastNext NEW_LINE DEDENT else : NEW_LINE INDENT next = arr [ ( i + 1 ) % len ( arr ) ] NEW_LINE DEDENT DEDENT