iterate i and j to get all subarrays
for i in range ( 0 , n ) : NEW_LINE INDENT currSum = 0 NEW_LINE for j in range ( i , n ) : NEW_LINE INDENT currSum += arr [ j ] NEW_LINE currDev = abs ( K - abs ( currSum ) ) NEW_LINE DEDENT DEDENT