Where is the best place to retire in the United States? It’s complicated.

While New York may offer the best quality of life for retirees, it’s too pricey for many. Alabama may be one of the cheapest places to live, but the quality of health care there leaves a lot to be desired. And while Minnesota may offer the best health care — and a quality of life second only to that in New York — it is also very expensive.

These are among the findings of a recent study by the financial website WalletHub, which ranked the 50 states and the District of Columbia in three categories: affordability, health care and general quality of life. Using 31 metrics and assigning a point value to each, the site then came up with an overall score for each state. Here are the five that ranked best — and the five that ranked the worst.