#include <stdio.h>
int main()
{
FILE *input = fopen("input.txt", "r");
FILE *output = fopen("output.txt", "w");
int n, k;
fscanf(input, "%i %i\n", &n, &k);
printf("%d", k);
int array[n];
int buffer;
int i = 0;
while(fscanf(input, "%i", &buffer))
{
array[i] = buffer;
i++;
}
fclose(input);
double maxNEDOVOLEN = 100000000;
int floorOfNedovolen = 1;
for(int floor = 2; floor < k; floor++)
{
int NEDOVOLEN = 0;
for(int i = 0; i < n; i++)
{
int neededFloor = array[i];
printf("%d", neededFloor);
if(neededFloor < floor)
{
NEDOVOLEN += floor - neededFloor;
}
else
{
NEDOVOLEN += (neededFloor - floor) * 2;
}
}
printf("%d", NEDOVOLEN);
if(NEDOVOLEN < maxNEDOVOLEN)
{
maxNEDOVOLEN = NEDOVOLEN;
floorOfNedovolen = floor;
printf("%d", NEDOVOLEN);
}
}
fprintf(output, "%i", floorOfNedovolen);
fclose(output);
return 0;
}