The revenue from selling [math] items is [math], and the total cost is [math]. Write a function that gives the total profit earned, and find the quantity which maximizes the profit.

Profit [math]

Quantity maximizing profit [math]