give integer array instruction ask create sorted array element instruction you start container num for element leave right instruction insert num the cost insertion minimum followingthe number element currently num strictly instructionsithe number element currently num strictly great instructionsifor example insert element 3 num 1235 cost insertion min2 1 element 1 2 3 element 5 great 3 num 12335return total cost insert element instruction num since answer large return modulo 109 7 Example 1input instruction 1562output 1explanation Begin num Insert 1 cost min0 0 0 num 1insert 5 cost min1 0 0 num 15insert 6 cost min2 0 0 num 156insert 2 cost min1 2 1 num 1256the total cost 0 0 0 1 1example 2input instruction 123654output 3explanation Begin num Insert 1 cost min0 0 0 num 1insert 2 cost min1 0 0 num 12insert 3 cost min2 0 0 num 123insert 6 cost min3 0 0 num 1236insert 5 cost min3 1 1 num 12356insert 4 cost min3 2 2 num 123456the total cost 0 0 0 0 1 2 3example 3input instruction 133324212output 4explanation Begin num Insert 1 cost min0 0 0 num 1insert 3 cost min1 0 0 num 13Insert 3 cost min1 0 0 num 133insert 3 cost min1 0 0 num 1333insert 2 cost min1 3 1 num 12333insert 4 cost min5 0 0 num 123334insert 2 cost min1 4 1 num 1223334insert 1 cost min0 6 0 num 11223334insert 2 cost min2 4 2 num 112223334the total cost 0 0 0 0 1 0 1 0 2 4 Constraints1 instructionslength 1051 instructionsi 105