Money change problem (using lower_bound )

bool compare (int a,int b) {
return a<=b;
}
example: int a[ ] = {10,20,30,40,50,60, 70}
if i do *(lower_bound (a, a+7 , 40 , compare)) ;
then this function returns the value 50 , ideally it should have returned 40 , i dont understand why this is happening ? please tell?
same concept is used in money change problem . so i dont understand it as well.

hi @dahiya.shubham1234 u need to substract 1 from it, in lecture se showed the eg