use array subtraction and advance output