Plug in ML = 200. Do you get 700? Seems more like 300.
If you really want to express it in that form (which, uh, why bother, when I gave you a perfectly reasonable way to do it?), then you need to have it do:
int penalty = max(0, ml-20) + max(0, ml-40) + max(0, ml-60) + max(0, ml-80) + max(0...