s = [1, 2, 2, 3, 4, 4, 5] for i in eachindex(s) curr = s[i] i > 1 && curr == prev && println(i) prev = curr end