Learn first
Programs follow precise instructions
A program is a set of instructions. A variable stores a value. A condition chooses between paths. A loop repeats steps. Output is the result produced.
How to work it out Trace one instruction at a time. Keep a record of values and check exactly when a condition or repeated step is evaluated.
A separate example In a separate trace, start with n = 2, add 3, then double n. The two instructions happen in order: 5 is an intermediate value before the final result.
Copying a matching value does not itself stop a loop. Put the early scan exit immediately after copying inside the successful branch. End closes a block; after the loop, Main continues. With the rule value >= 2, fallback 0 cannot be confused with a valid match.
Worked example
A faulty scan of [1, 3, 2] copies 3, then keeps scanning and copies 2. It reports 2, the last match, instead of the required first match 3. Stop after the first copy to preserve 3.
A robot left out one instruction
Faulty program: set result to 0; for each value in [1, 4, 2], if value >= 2, copy value to result; end If; end For each; report result. There is no Stop instruction. The task is to find the FIRST value at least 2. Use the given order; item numbers begin at 1.