Solves task 5 maximal sum in matrix