If you array is sorted, then you can quick search (for example, using binary search) any single element, belong to your range. Thereafter, add your increment value to elements before and after entry point.
For example, lets array contains ints.
So code will be like:
int *p;
// try to fill array from begin to element range_max
if(your_array[0] >= range_min) {
for(p = your_array; p < your_array + elems_qty; p++)
if(*p <= range_max)
*p += delta;
else
break;
return; // head of array filled
}
// try to fill array from end to element range_min
if(your_array[elms_qty - 1] <= range_max) {
for(p = your_array + elms_qty - 1; p >= your_array; p--)
if(*p >= range_min)
*p += delta;
else
break;
return; // tail of array filled
}
// There is range somewhere inside array
int avg_element = (range_min + range_max) / 2;
int *avg_ptr = bsearch(&avg_element, your_array, elems_qty, sizeof(int), int_comparator);
for(p = avg_ptr; *p >= range_min; p--)
*p += delta;
for(p = avg_ptr; *p <= range_max; p++)
*p += delta;