Algorithm with arrows