local n, a, b = io.read("*n", "*n", "*n") -- if n == 2 then -- print(math.min(a-b-b,-a)) -- end local z = 0 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 z = math.min(c1, c2) else local c1 = a * (n - 1) - b * n local c2 = -a * (n - 1) local c3 = 0 if 2 < n then c3 = -a * (n - 2) + a - b - b end --[[ (1, -1,)*k + (1, 1, )*(hn-k) => -2a * k + ((hn - k) * 2 - 1) * a - 2b * (hn - k) = k(-2a-2a+2b)+... ]] z = math.min(c1, c2, c3) end print(z)