import Control.Applicative
import Data.List
main = inputOutput
inputOutput = do
maxPair xxs p
= f
0 =<< reverse $ sort xxs
where
f r (x:xs) (y:ys)
| x == y = r
| l > p = f r xs (y:ys)
where l = x + y
f r _ _ = r
aW1wb3J0IENvbnRyb2wuQXBwbGljYXRpdmUKaW1wb3J0IERhdGEuTGlzdAoKbWFpbiA6OiBJTyAoKQptYWluID0gaW5wdXRPdXRwdXQKCmlucHV0T3V0cHV0IDo6IElPICgpCmlucHV0T3V0cHV0ID0gZG8KICBbbiwgZF0gPC0gbWFwIHJlYWQgPCQ+IHdvcmRzIDwkPiBnZXRMaW5lCiAgbHMgICAgIDwtIG1hcCByZWFkIDwkPiBsaW5lcyA8JD4gZ2V0Q29udGVudHMKICBsZXQgKHBzLCBtczApID0gc3BsaXRBdCBuIGxzCiAgICAgIG1zID0gdGFrZSBkIG1zMAogIHB1dFN0ckxuICQgdW5saW5lcyAkIG1hcCBzaG93ICQgbWFwIChtYXhQYWlyIHBzKSBtcwoKbWF4UGFpciA6OiBbSW50XSAtPiBJbnQgLT4gSW50Cm1heFBhaXIgeHhzIHAgPSBmIDAgPTw8IHJldmVyc2UgJCBzb3J0IHh4cwogIHdoZXJlCiAgICBmIHIgKHg6eHMpICh5OnlzKQogICAgICB8IHggPT0geSAgICA9IHIKICAgICAgfCBsID4gcCAgICAgPSBmIHIgeHMgKHk6eXMpCiAgICAgIHwgb3RoZXJ3aXNlID0gZiAobWF4IGwgcikgKHg6eHMpIHlzCiAgICAgICAgd2hlcmUgbCA9IHggKyB5CiAgICBmIHIgXyAgICAgIF8gID0gcgo=