The given information compares Mary's and Charlie's ages to David's age. So use David's age as the variable:
x = David's age
x+16 = Mary's age (she is 16 years older than David)
x+13 = Charlie's age (David is 13 years younger than Charlie, so Charlie is 13 years older than David)
The sum of their ages is 62:
Solve using basic algebra.
Then remember the question asks for Mary's age, which is x+16 -- not just x.
Let Mary's age be M
Then David's is: M - 16, and Charlie's is: M - 16 + 13. or M - 3
Since all ages sum to 62, we get: M + M - 16 + M - 3 = 62
3M = 81
M, or Mary is: