Ruben Amorim has agreed to become AC Milan's head coach on a two-year contract, ending the Italian club's search for a manager and freeing Manchester United from the bulk of his £16.7m severance package.