google – SEO Safe way to permanently delete thousands of outdated pages

Our site is a huge one with about half a million pages built over the years. Many pages rank well for competitive keywords and have attracted high-quality link equity over the years. However, looking now, we have come to a conclusion that about 25% or about 100,000 pages are outdated and don’t bring us any value in terms of revenue. Instead, they cost us server resources to maintain. We are planning to remove these pages PERMANENTLY. What could be the safe way to remove them without negatively affecting the SEO of the REMAINING pages?

PS: Kindly help me with appropriate status code and duration (all at once or gradually)..