So run your loop and count the number of occurrences of a value in a row. When it changes you know how many the previous value was:
Values: 1, 7, 5, 4, 4, 4, 0, ...
Prev : ? 1 7 5 4 4 4 0
Count : 0 1 1 1 2 2 3
It the count is 3, you can print the value - 4 - and the start position from the current index - 3.
Each time it changes, set the count to 1 and save the value for the next time round the loop.
Give it a try on paper, and you'll see what I mean.