We’re rarely inclined to cheer New York, but Thursday’s announcement that Amazon has withdrawn its plans to open a second headquarters in Long Island City is deserving of a shout-out.

Amazon changed its mind after fierce public and political opposition to its plans and the $3 billion incentive package that officials offered the world’s largest public company. There are lessons here for both Amazon and our local elected officials.

Don’t ignore the public. Bad enough that the secretive Amazon bidding process had officials from around the country, including Philadelphia, stumbling over themselves to concoct the sweetest of sweetheart deals and expensive giveaways. The process also completely cut the public out of the equation, and out of the conversation.

Had they held a community meeting or two in New York City, it wouldn’t have come as a surprise to Amazon that many New Yorkers were not excited at all about winning the bid. Some doubted the job numbers promised by Amazon in exchange for tax breaks. Others just didn’t want Amazon in their neighborhood. Concerns included pressure on an already burdened subway system and the gentrification that Amazon would bring with it. The algorithms Amazon built its business on will only take you so far. You can’t win the long game if you cut out people.

People don’t trust political math. New York officials first celebrating the Amazon win touted the unprecedented creation of 25,000 to 40,000 jobs, and the fact that revenues to the city and state would be about a $1 billion a year over 25 years.

The big question is not whether that math is correct, but whether people believe that revenue will make a material improvement in their lives.

For example, New York has big infrastructure problems, particularly in its mass transit system — problems that are happening during relatively good times. That raises questions about how wisely public money is being managed and spent. And if people can’t trust that, even a potential influx of billions isn’t likely to impress them.

A case in point: the legalization of gambling in Pennsylvania has brought billions of dollars into the state in the last decade. That hasn’t solved massive challenges the state faces, nor eased serious budget problems (in part because of the revenue allocated to the horse race industry.) So when the next so-called salvation appears on the horizon -— casinos, fracking, Amazon, or whatever -— people have learned to be skeptical about just how they will benefit.

Amazon says it is not going to search for a different location, and will shift the employment to Virginia, its second site. Will Philadelphia officials be able to resist the temptation to try to change the company’s mind? We hope so. The city spent more than $500,000 on its bid, that was done in secrecy. It was willing to give $1.1 billion and the state was willing to give $4.6 billion in tax breaks for Amazon to choose Philadelphia.

We’re sure New York officials are apoplectic that Amazon had a tantrum and took its ball home. But maybe next time, they’ll include the community in the decision-making.