Doubt in video concept

At 27:50 sir told that (2(sum-n)+n) will prevent overflow but how

hi @siddharth9k9

as sum is very large number so multiplying it with 2 will overflow the range
so what we do is that we reduce the nos by n and then multiply with 2 and then add n

the formula is same but this will prevent overflow

i hope you understand now.