Task: Program Execution
Input (English): Q, 5165, 5251, 5097, 1037, 939, 8989, 8461
Output (English): 34939