Mr. M traveled 5 miles fewer than twice the number of miles on Tuesday than Monday. On Wednesday, he traveled 40 miles more than the square number of miles traveled on Monday. If the total miles traveled was 1,024, Write an equation to represent the total miles traveled on Monday, Tuesday, and Wednesday.