func main() var n: int :: cui@inputInt() var k: int :: cui@inputInt() var a: []int :: #[n]int for i(0, n - 1) do a[i] :: cui@inputInt() end for var rnd: lib@Rnd :: lib@makeRnd(lib@sysTime() $ bit32) var ans: int :: 0 var use: []bool :: #[n]bool for(1, 4) var map: dict :: #dict var mod: int :: rnd.rnd(2 ^ 50, 2 ^ 51) for ii(0, 2 ^ n - 1) var id: int :: ii var cnt: int :: 0 for i(0, n - 1) do use[i] :: (id % 2 = 1) if(use[i]) do cnt :+ 1 end if do id :/ 2 end for if(cnt >= k) var mul: int :: 1 for i(0, n - 1) if(use[i]) do mul :* a[i] do mul :% mod end if end for do map.add(mul, true) var sum: int :: 0 for i(0, n - 1) if(use[i]) do sum :+ a[i] end if end for do map.add(sum, true) end if end for do ans :: [ans, ^map].max() end for do cui@print("\{ans}\n") end func