var used: []bool var k: []int func main() var n: []char :: cui@input() do @k :: #[^n]int for i(0, ^n - 1) do @k[i] :: n[i] $ int - '0' $ int end for do @used :: #[^n]bool var ans: int :: f() do cui@print("\{ans}\n") func f(): int var res: int :: 0 for i(0, ^@k - 1) if(@used[i]) skip i end if if(@k[i] = 0) skip i end if for j(i + 1, ^@k - 1) if(@used[j]) skip j end if for k(j + 1, ^@k - 1) if(@used[k]) skip k end if var a: int :: @k[i] var b: int :: @k[j] var c: int :: @k[k] if(a <> b & b = c) do @used[i] :: true do @used[j] :: true do @used[k] :: true do res :: [res, f() + a * 100 + b * 11].max() do @used[i] :: false do @used[j] :: false do @used[k] :: false end if end for end for end for ret res end func end func