This decision mostly comes down to condition and priorities. Last year’s flagship can still be the better buy if you want stronger cameras, premium build, faster performance and higher-end extras. A new midrange phone is often safer if you value a fresh battery, full warranty, longer remaining support and lower repair risk.
If the flagship is used, check battery health, display condition, water damage, repair history and whether parts are easy to source. A cheap flagship with a tired battery or replaced display can quickly become expensive.
My rule: choose the older flagship when it is in excellent condition and its remaining software support is still comfortable for your ownership period. Choose the new midrange when reliability, warranty and predictable long-term cost matter more than flagship-level cameras or performance.