Eating foods with an array of different colours may help you stay sharp.
The NHS has long advised people aim for at least five different portions of fruits and vegetables a day – whether it be fresh, canned, frozen, juiced or dried produce.
A Harvard study has now reinforced the suggestion our plate should be made up of a rainbow of colours.
Scientists analysed more than 77,000 middle-aged adults, who were tested on their diet and cognitive ability over 20 years.
Those who ate the most flavonoids – potent antioxidants that give some foods their colour – were 20% less likely to endure cognitive decline.
"The people in our study who did the best over time ate an average of at least half a serving per day of foods like orange juice, oranges, peppers, celery, grapefruits, grapefruit juice, apples and pears," said Dr Walter Willett.
"While it is possible other phytochemicals [plant compounds] are at work here, a colourful diet rich in flavonoids seems to be a good bet for promoting long-term brain health.
"It's never too late to start, because we saw those protective relationships whether people were consuming the flavonoids in their diet 20 years ago or if they started incorporating them more recently."
The study's participants had an average age of 49 at the start of the study. Over the next 20 years, they completed several questionnaires that asked how often they ate various foods.
They were also asked questions like "Do you have more trouble than usual remembering recent events?" and "Do you have more trouble than usual remembering a short list of items?" twice over the two decades.
The participants in the group with the highest flavonoid intake consumed around 600mg of the antioxidants every day, compared to around 150mg every 24 hours in the lowest-intake group.
For context, strawberries contain around 180mg of flavonoids per 100g serving, while apples have about 113mg per 100g portion.
Watch: Getting your five-a-day helps you live longer
Overall, the results – published in the journal Neurology – reveal the highest flavonoid consumers experienced 20% less cognitive decline than those with the lowest intake.
This remained true after the scientists accounted for the participants' age and total calorie consumption.
When looking at individual flavonoids, so-called flavones – found in certain spices and yellow or orange produce – were associated with a 38% reduction in cognitive decline.
This is equivalent to a person's "internal age" being three to four years younger than their physical age, according to the scientists.
Yellow or orange peppers, for example, contain around 5mg of flavones per 100g serving.
Anthocyanins – in blueberries, cherries and blackberries – were linked to a 24% reduction in cognitive decline. Blueberries specifically have 164mg of anthocyanins per 100g portion.
The scientists have stressed the participants self-reported their diet, which may have reduced the accuracy of the results.
Nevertheless, Dr Willett added: "There is mounting evidence suggesting flavonoids are powerhouses when it comes to preventing your thinking skills from declining as you get older.
"Our results are exciting because they show that making simple changes to your diet could help prevent cognitive decline."
Watch: Vegetarians have fewer disease markers