local n, a, b = io.read("*n", "*n", "*n") if n % 2 == 1 then --[[ -a(n-1)-b <= a(n-1)-bn b(n-1)<=2a(n-1) b<=2a ]] local c1 = a * (n - 1) - b * n local c2 = -a * (n - 1) - b print(math.min(c1, c2)) else local c1 = a * (n - 1) - b * n local c2 = -a * (n - 1) local hn = mfl(n / 2) --[[ (1, -1,)*k + (1, 1, )*(hn-k) => -2a * k + ((hn - k) * 2 - 1) * a - 2b * (hn - k) = k(-2a-2a+2b)+... ]] print(math.min(c1, c2)) end