#include<stdio.h>

// A recursive binary search function. It returns
// location of x in given array arr[l..r] is present,
// otherwise -1
int binarySearch(int arr[], int l, int r, int x)
{
   if (r >= l)
   {
        int mid = l + (r - l)/2;

        // If the element is present at the middle
        // itself
        if (arr[mid] == x)
            return mid;

        // If element is smaller than mid, then
        // it can only be present in left subarray
        if (arr[mid] > x)
            return binarySearch(arr, l, mid-1, x);

        // Else the element can only be present
        // in right subarray
        return binarySearch(arr, mid+1, r, x);
   }

   // We reach here when element is not
   // present in array
   return -1;
}

//main function
int main() {
    int n;
    int k;
    printf("Enter number of chair and number of parasol stands");
    printf("\n");
    scanf("%d",&n);
    scanf(" %d",&k);

    int chair[100];
    printf("Chair indices:");
    printf("\n");
    int i;
    for(i=0;i<n;i++)
    {
        int tr;
        scanf("%d",&tr);
        chair[i]=tr;
    }

    //Calculating area to cover
    int lentocover=0;
    for(i=0;i<chair[n-1];i++)
    {
        int position = binarySearch(chair, 0, n-1, i);
        if(position != -1)
        {
            lentocover=lentocover+(chair[position+1]-chair[position]);
        }

    }

    //the required result is lentocover/number of parasol stands
    int result=lentocover/k;
    printf("\nWidth of parasol required is :%d",result);
}
