Question on distribution (newsagent profit problem)

Screenshot 2018-11-27 at 10.00.08 PM.png

I know that the given distribution is a discrete uniform distribution to model the number of customers. How do I link this to the two possible events (given in the hint) to get the expected value of profit as a function of n, and how do I get this function when the profit function seems to be "split" into 2 cases?
I just did this using a computer and got n=185 as the max profit. You do certainly have to consider the two cases
Case 1: You have the exact or less amount of newspapers as customers
Case 2: You have more newspapers than customers

As for a closed solution, my suggestion would be to determine a function of n that returns the expected profit across all x's. That function would be peace-wise at the beginning to account for both cases, but potentially could be transformed into a single equation. Once a single equation is found, than differentiate to find a local maximum and then round to the nearest integer.