as ruler kingdom army wizard commandyou give 0indexed integer array strength strengthi denote strength ith wizard for contiguous group wizard ie wizard strength form subarray strength total strength define product follow valuesthe strength weak wizard groupThe total individual strength wizard groupreturn sum total strength contiguous group wizard since answer large return modulo 109 7A subarray contiguous nonempty sequence element array example 1input strength 1312output 44explanation the follow contiguous group wizard 1 1312 total strength min1 sum1 1 1 1 3 1312 total strength min3 sum3 3 3 9 1 1312 total strength min1 sum1 1 1 1 2 1312 total strength min2 sum2 2 2 4 13 1312 total strength min13 sum13 1 4 4 31 1312 total strength min31 sum31 1 4 4 12 1312 total strength min12 sum12 1 3 3 131 1312 total strength min131 sum131 1 5 5 312 1312 total strength min312 sum312 1 6 6 1312 1312 total strength min1312 sum1312 1 7 7the sum total strength 1 9 1 4 4 4 3 5 6 7 44example 2input strength 546output 213explanation the follow contiguous group wizard 5 546 total strength min5 sum5 5 5 25 4 546 total strength min4 sum4 4 4 16 6 546 total strength min6 sum6 6 6 36 54 546 total strength min54 sum54 4 9 36 46 546 total strength min46 sum46 4 10 40 546 546 total strength min546 sum546 4 15 60the sum total strength 25 16 36 36 40 60 213 Constraints1 strengthlength 1051 strengthi 109