Let max be mary's older brother.
Let max age be y
and mary age be x
Their sum is 8 and difference is 2, so can write:
x + y = 8
and
y - x = 2
Now we add up the two equations:
x + y = 8
-x + y = 2
-----------------
2y = 10
y = 10/2 = 5
Now,
x + y = 8
x + 5 = 8
x = 8 - 5
x = 3
So,
x = 3
y = 5
Mary is 3 years old and Max is 5 years old.