Sum is not correct

if we enter array elements as all 1 in a 3*3 matrix the answer should be 100

use this condition it will give correct ouput

                sum+=psa[Bi][Bj];
                if(Lj>0)sum-=psa[Bi][Lj-1];
                if(Li>0)sum-=psa[Li-1][Bj];
                if(Li>0&&Lj>0)sum+=psa[Li-1][Lj-1];

MODIFIED CODE

i hope this help
if you have more doubts regarding this feel free to ask
if your doubt is resolved mark it as resolved from your doubt section inside your course