Just re-write the English into math language.
Let x be the 1st number and x+1 the second:
x² + (x+1)² = 31 - 2(x+1)²
Expanding this equation gives: 4x²+6x-28 =0
Solve for x this quadratic equation: results: x = 2 and x = -7/2, since the numbers are consecutive INTEGERS, then only x=2 is valid. HENCE:
The 1st number is 2 and the 2nd is 3