Codeforces 564A

Im not able to understand the underlying concept from the video. could you please provide an explanation

This link https://codeforces.com/blog/entry/67511 has decent comments with good explanation , so that should help you with intuition and the way to solve this question. The question is being discussed as Div2-c/ Div-1 A.