At long last, after lots of calculus errors, solution for 296 (runs in 2 mins).