Hello, You have an array of 10000, but you use 2*L and 2*R, since the numbers for L and R will be as high as 9999, your program will be accessing memory outside of the array. for example, with this input: 4090 5000 5000 your program gives: 4090 5000 5000 1073833120 5000 -1073744880 5001 -1073744764 ...