Hello everybody. I am trying to do something with a spreadsheet and not sure how to work the formula. I have seven columns and seven rows. The column starts at F and the rows start and 1. The formula I have is this:

=IF(SUM(K1:K5)>=30,SUM(K1:K5)-30,IF(SUM(K1:K5)>=20,SUM(K1:K5)-20,IF(SUM(K1:K5)>=10,SUM(K1:K5)-10,IF(SUM(K1:K5)<10,SUM(K1:K5)))))

This is in cell K6. I would like this formula to also be able to look at cells L6 and L7, and if L7 is larger than L6, subtract 1 from result of the formula in K6. Can something like this be done? Thank you in advance for any help that can be given.