b [ 1 ] will contain the day on which we are getting the maximum profit
$ b [ 1 ] = $ diff_day ; for ( $ i = 1 ; $ i < $ n ; $ i ++ ) { $ l = 0 ; $ r = $ diff_day ; $ sum = 0 ; for ( $ j = $ n - 1 ; $ j >= $ i ; $ j -- ) {