A young elephant delicately lifts the barrier blocking the railroad tracks in India's Chapramari Wildlife Sanctuary and slips under. Once across the tracks, it gingerly steps over another obstruction.

“It looks as though this elephant has done this before,” says Joyce Poole, an elephant behavior expert and co-founder of Elephant Voices.

Elephants have long been famous for their smarts—they have long-term memory, can use tools, and maintain complex social groups. But increasingly, elephants are being recognized for their problem-solving abilities. And this ingenuity can get them in trouble.

Scientists collected proof of this in 2011, when they discovered that elephants, like humans, can have that creative “Aha!” moment. Researchers working with three Asian elephants at the National Zoo in Washington, D.C., wanted to see if the elephants would use tools to retrieve food outside their reach.

The scientists first gave the animals sticks, which didn’t work because elephants lose the ability to smell with their trunk while holding something. Next, the researchers put out objects that the elephants could use as stepping stools.

One elephant, a seven-year-old named Kandula, took to it. When he couldn't reach a bamboo branch laden with fruit, he rolled a cube below the treat and boosted himself up (watch the video here). When the box was taken away the elephant adapted other objects for leverage.

Asian elephants, like the one seen crossing the train tracks, are increasingly threatened. Today, the population in India has shrunk to between 20,000 and 25,000 wild elephants. As their forests and savannas are depleted, elephants searching for food increasingly come into contact with humans. The results are often disastrous for both.

Across Africa and Asia, electric fences have been installed to keep out the hungry beasts, which can easily destroy a farmer’s crop. This doesn’t always work. In October, Indian elephants realized that the power supply on a fence meant to keep them out of a dump was off and they broke through for a garbage feast.

“Elephants are highly intelligent animals whose ability to get around human-made barriers is both a blessing and a curse,” says Nilanga Jayasinghe, an Asian elephant expert at the World Wildlife Fund. She’s working to develop an early warning system in countries like India that will allow conservationists to "stay one step ahead of the elephants” and intervene in dangerous situations before elephants or humans get hurt. (Learn about one text-based system.)

These problem-solving abilities are especially dangerous in India, where the trains that run through India’s national parks can be deadly. Activists say they have unsuccessfully petitioned the railway authorities to reduce the speed of trains as they pass through elephant habitat. In 2013, a herd of elephants from the same sanctuary was hit by a speeding train as they tried to cross the tracks, killing at least seven. The rest of the 40-strong herd returned after the train left and stood over their dead—a mourning ritual elephants have been studied doing.