Baby boomers are set to retire, all 74 million of them, and a good chunk of them will be relocating to towns across the U.S.

A new ranking takes a look at not only which towns may be the most attractive to retirees, but also the most expensive for buying or renting a home.

Realtor.com examined the 500 largest metropolitan areas, focusing on where at least a quarter of the population is aged 60 and up, to get an idea of which cities will face the largest influx of retirees in their community.

They also looked at a range of factors, especially cost of living, to determine which retirement towns are the most expensive.

Realtor.com ranked each of the metros by the total cost to pay down a 15-year mortgage on a median-priced home within them. Buyers were assumed to have a 20 percent down payment and a 5 percent mortgage interest rate.

The ranking also focused on towns where at least a quarter of the population is aged 60 and up and where the most folks in this age group moved to between 2011 and 2015. "We included only markets that had a high share of realtor.com listings with mentions of 'retirement,' 'aging in place,' 'ground-floor master bedrooms' and similar phrases," the report said.

These towns, in ascending order, were at the top of the list in terms of high housing costs:

10. Ocean City, N.J.

This New Jersey coastal city offers classic Jersey Shore beaches, amusement parks and a boardwalk. Real estate prices currently are $413 per square foot and the median home price is $629,900.

 

 

9. Medford, Ore.

Forbes named Southern Oregon as a top global wine destination, and Medford is the heart of the area. The Rogue Valley has hiking, fishing and rafting for the active retirement community. Realtors.com lists housing at $185 per square foot and the median home price is $315,450.

 

 

8. Prescott, Ariz.

Enjoy golfing, hiking and the history of the Old West in this Northern Arizona town. Expect to pay $206 per square foot in this desired desert destination. The median home price is $449,900, with a median seasonal rental price of $1,950 per month.

 

 

7. Hilton Head Island, S.C.

The foot-shaped island is known for its beaches and golf courses. If you plan on renting, the median seasonal rental rate is $2,700 per month, while the median home price is $439,000.

 

 

6. Bend, Ore.

If you like caves, mountains and lakes, then you may try retiring in Bend, with its proximity to the Cascades. The median home price is $474,900. Seasonal rentals average $1,790 per month.

 

 

5. Naples, Fla.

Naples has one of the largest concentrations of millionaires in the country. Located on the western coast of Florida, expect the median home to run around $458,600. The county has one of America’s highest median life spans, at 83.4 years, as noted by realtor.com.

 

 

4. Barnstable, Mass.

The Cape Cod location can be pricey, with neighbors coming from Boston or New York to retire. Residents aged 60 and up comprise about 38.9 percent of the population. The median home prices is $429,000, with the price per square foot at $276.

 

 

3. Santa Fe, N.M.

The artsy vibe of this Southwest town attracts international boomers. Retirees can enjoy the numerous art galleries, natural spring spas and golf courses, but the home prices are lofty, with a median price of $568,900.

 

 

2. Santa Rosa, Calif.

About an hour north of San Francisco, Santa Rosa offers access to Wine Country.. The median home price is $639,000 with the median price per square foot at $394.

 

 

1. San Luis Obispo, Calif.

If you plan to retire along the coveted Pacific Coast Highway, the median home price is $729,600. The proximity to San Francisco and San Diego make this an easy jump for most retirees in the Bay Area and Southern California who want to live near the ocean.

The full report can be viewed here.