Desert locusts develop bigger brains when swarming due to the mental challenges of living in a crowd, scientists have learned.
The insects are famous for the Biblical scale of their crop-stripping swarms, which can have devastating effects on livelihoods and economies.
However, desert locusts often also adopt a solitary lifestyle, living alone and actively avoiding other members of their species.
The phase of life the insects are in - swarming or solitary - has a dramatic effect on their brains, according to the new research.
Scientists working with colonies of swarming locusts converted some of the insects into "loners" by keeping them isolated for three generations.
Comparing the size and shape of the locusts' brains revealed extraordinary differences.
Despite being smaller than solitary locusts, swarming locusts developed brains that were 30% larger.
The differences were most visible in regions of the brain dedicated to specific tasks.
In solitary locusts, parts of the brain dealing with vision and smell were proportionately larger. The brains of swarming locusts, in contrast, were far more developed in regions associated with learning and processing complex information.
"Their bigger and profoundly different brains may help swarming locusts to survive in the cut-throat environment of a locust swarm," said study leader Dr Swidbert Ott, from Cambridge University. "Who gets to the food first wins, and if they don't watch out, they themselves become food for other locusts.
"In a nutshell, you need to be brainier if you want to make it in the mayhem that is a locust swarm."
Brains geared for processing complex information would also be an advantage as swarming locusts moved from place to place searching for and assessing potential new food sources, he said.
The challenges of living in large groups and relying on varied and unpredictable sources of food were also believed to be key factors behind the brain enlargement of some vertebrates.
The findings are reported today in the journal Proceedings of the Royal Society B.