Consider the following cost information for a firm that operates in a perfectly competitive market. Labor is a variable input.

Q (quantity of output) Total cost ($)
0 15
1 25
2 45
3 75
4 110
5 165
6 225

Suppose that the market price is $20. State the condition for the optimal quantity of output. Using the condition, find the quantity of output that the firm should produce in the short run.