People love arguing about which cities in the United States are "the best" places to live. But what about the worst? Courtesy of a new survey by WalletHub, you might be shocked to learn that certain metros generally thought of as desirable rank highly on its latest "Do Not Move Here" list.

Such as? The sunny shores of Long Beach, CA, and Miami, FL.

To arrive at their conclusions, WalletHub compared 62 of the largest U.S. cities with a population over 300,000, ranking them based on 50 key metrics that fall into five main categories: affordability, economy, safety, education and health, and quality of life. The very best city in which to live was deemed to be Virginia Beach, VA.

As for the worst American city to live in? Few will be shocked to find perennially challenged Detroit, MI, leading the list.

According to WalletHub, Motor City's ignominious No. 1 ranking is due to a high percentage of the population living below the poverty line (around 40% according to the U.S Census Bureau), low income growth, and high crime.

But what gives with the low rankings of Long Beach (seventh-worst) and Miami (ninth)?

So what's wrong with Miami?

Affordability and safety are to blame for the low "livability" rankings of sun-kissed Miami, says WalletHub analyst Jill Gonzalez.

"The city has the highest housing costs out of the 62 cities we analyzed, as well as the lowest homeownership rate, at 31%," she says. "And residents in Miami have the second-lowest median household income, at just $31,051."

Like many of America's luxury meccas, Miami stands as a tale of real estate haves and have-nots. "Miami has a very large discrepancy between the very wealthy and the very poor," says Maryjo Shockey, a Realtor® with Keller Williams in Wellington, FL. "It shows as you drive downtown and see the run-down areas and then compare them the high-end apartments and shops just a few streets over.

"Miami has some beautiful sections, but they're sections where the average person could not afford to live," she says.

Long Beach: A long shot for livability?

Long Beach, CA, also cropped up on the "worst" list, due to subpar scores on cost of living.

"The city has the second-highest cost of living index among the cities we analyzed, and the seventh-lowest homeownership rate, at just 40%," says Gonzales. "It's not surprising, since housing costs are so high."

But some real estate experts say Long Beach is getting a bad rap. "It is sort of a hidden gem that offers a bit more affordably priced housing in the Southern California area, versus other beach cities," says Cara Ameer, a Realtor in the Jacksonville, FL, area.

For example, the median listing price in Newport Beach—Long Beach's neighboring beach town, to the south—is $2.3 million; the median listing price in Long Beach is $599,000.

Here are the top 10 best and worst large cities in the United States:

Worst cities:

Detroit, MI Memphis, TN St. Louis, MO Baltimore, MD Fresno, CA Indianapolis, IN Long Beach, CA Santa Ana, CA Miami, FL Cleveland, OH

Best cities: