In our teens and 20s, many of us feel unstoppable. But after age 30, everyday life starts to get a little harder. Knees ache, hangovers last two days, younger family members begin to outrun us and we can’t remember what we did with our keys. With aches, pains and busy schedules, exercise can be a low priority, especially when it won’t necessarily help our waistlines. But exercising as we age can help preserve muscle mass so we can go the distance. It can even help us remember our keys.

After we hit 35, most of us just aren’t as strong or as fast as we used to be. “In normal aging there are a lot of physiological things that happen that decrease performance over the years,” explains Myriam Paquette, an exercise physiologist at Laval University in Quebec City. She notes that the maximum amount of oxygen we can use (VO2 max) and our overall muscle mass decrease, and, along with them, the strength and power they provide.

Exercise training can keep some of these effects at bay. “As soon as you hit 35 or 40, you need to start doing resistance [exercise],” says John Hawley, an exercise physiologist at Australian Catholic University in Sydney. “You muscles are being remodeled constantly. “As the muscle gets older … it gets resistant to building up.” So the older people get, the harder they have to work to get — and keep — their gains.

For VO2 max, decreases in maximum oxygen can mean decreased athletic performance. But “if people do high intensity training, that can be delayed five to 10 years,” says Michael Joyner, a physiologist at the Mayo Clinic in Rochester, Minn.

Enough exercise can even keep older athletes racing with the pros — as long as they run far enough. Sian Allen and Will Hopkins at the Sports Performance Research Institute New Zealand in Auckland gathered studies of peak competitive performance and found that for elite athletes, peak performance age increased as distance increased. Athletes who compete in short swimming events tended to peak at 20, while ultra-distance cyclists peaked at 39, they reported in the June 2015 Sports Medicine. Some of this may be for social reasons, Joyner notes — until the past few decades, distance events didn’t have the focus or coaching (or funding) that is characteristic of sprint distances.

Older athletes may not be at peak VO2 max and muscle mass, but they can take advantage of something only age provides — experience. “Being able to react to changes in conditions, mental resilience, pacing strategies, these are things you are able to accumulate,” Allen says. She suggests that learning and experience may assist people competing at later ages across longer distances, “As opposed to shorter distances that…[are] more raw expression of power.”

Age also takes a toll on the brain. This isn’t just for the retirees: Word recall, spatial reasoning and even processing speed can begin to decline in the early 30s. One of the brain benefits of exercise is an increase in the birth of new brain cells. As we get older, exercise proves protective both for brain structure and function. Sedentary people show decreases in white and gray matter as they age. Physical activity, even walking 72 blocks per week, helps preserve gray matter in older adults in areas such as the hippocampus — a brain area important for memory. Keeping up aerobic activity also improves cognitive control in middle-aged and older people — including tasks such as planning and working memory.

Some of this might be associated with the fact that keeping up aerobic activity means retaining VO2 max, says Takashi Tarumi, an exercise physiologist at the University of Texas Southwestern Medical Center in Dallas. Middle-aged endurance athletes with higher VO2 max also have better brain blood flow. That better blood flow is associated with better performance in memory and attention tasks — key to remembering where exactly you put those keys. Tarumi and his colleagues published their results in a 2013 study in the Journal of Hypertension.

While working out for weight loss or a beach body may be an exercise primarily in frustration, exercise is far from fruitless. It’s an investment toward stronger muscles and better endurance — whether for marathons or getting up the stairs. And staving off cognitive decline is probably well worth a few hours in the gym.