The cost function is total costs for the units produced. Don't multiply by the units.

Profit = revenues - costs

= (units*price) - costs

= x(1600-4x) - (40x+2000).

However, when I maximize this I still don't arrive at the answer given. I get x = 1560/8 = 195, p = 1600-4x = 820, not 824. Profits are different, too.