semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
float jueduizhi(float x)
{
	if(x<0)
		x=-x;
	return(x);
}

void main()
{
	int x[300],n,i,geshu=1;
	float ave,sum=0.0,d;
	int p1,p2;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&x[i]);

		
	for(i=0;i<n;i++)
		sum=sum+x[i];
	ave=sum/n;

	p1=x[0];p2=x[0];d=jueduizhi(ave-x[0]);
	for(i=1;i<n;i++)
		if(jueduizhi(ave-x[i])>d)
		{
			d=jueduizhi(ave-x[i]);
			p1=x[i];
			p2=p1;
		}
		else if(jueduizhi(ave-x[i])==d)
		{
			p2=x[i];
		}
if(p1>p2)
printf("%d,%d",p2,p1);
else if(p1<p2)
printf("%d,%d",p1,p2);
else printf("%d",p1);
	}
void main(void)
{
	int a[300], b[300];
	int n, i, j;
	float max, sum = 0, ave;
	scanf("%d", &n);
	for(i = 0;i < n;i ++)
	{	
		scanf("%d",&a[i]);
		sum += a[i];
	}
	ave = sum / n;
	for(i = 0;i < n;i ++)
	{
		for(j = 0;j < n - 1;j ++)
			if(a[j] > a[j + 1])
			{
				max = a[j];
				a[j] = a[j + 1];
				a[j + 1] = max;
			}
	}
	if(ave - a[0] > a[n - 1] - ave)
		max = ave - a[0];	
	else
		max = a[n - 1] - ave;
	j = 0;
	for(i = 0;i < n;i ++)
		if(fabs(fabs(a[i] - ave) - max) < 1e-5)
		{	b[j] = a[i];
			j++;
		}
	for(i = 0;i < j - 1;i ++)
		printf("%d,",b[i]);
	printf("%d",b[j - 1]);
}
int main()
{
    void sort(int a[], int n);
    int a[300 + 10] = {0};
    int i;
    double sum = 0, aver;
    int n;

    cin >> n;
    for (i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    aver = sum / n;
    sort(a, n);
   // for (i = 0; i < n; i++)
   //     cout << a[i] << end l;
    if(fabs(aver - a[0] - a[n - 1] + aver) < 1e-10)
        cout << a[0] << "," << a[n - 1] << endl;
    else if(aver - a[0] > a[n - 1] - aver)
        cout << a[0] << endl;
    else if(aver - a[0] < a[n - 1] - aver)
        cout << a[n - 1] << endl;

    return 0;
}

void sort(int a[], int n)
{
    int i, j;
    for (i = 0; i < n - 1; i++)
    {
        for(j = i + 1; j < n; j++)
        {
            if(a[i] > a[j])
            {
                int t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
        }
    }
}
struct point
{
	int num;
	float distance;
};
int main()
{
	struct point ans[300];
	float ave;
	int n,i,s=0,j;
	struct point temp;
	int a[300];
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		s=a[i]+s;
	}
	ave=(s*1.0)/n;
	for(i=1;i<=n;i++)
	{
		ans[i].num=a[i];
		if(ave>a[i]) ans[i].distance=ave-a[i];
		else ans[i].distance=a[i]-ave;
	}
	for(i=n-1;i>=1;i--)
	{
		for(j=1;j<=i;j++)
		{
			if(ans[j].distance<ans[j+1].distance)
			{
				temp=ans[j];
				ans[j]=ans[j+1];
				ans[j+1]=temp;
			}
		}
	}
	printf("%d",ans[1].num);
	for(i=2;i<=n;i++)
	{
		if(ans[i].distance==ans[1].distance)
			printf(",%d",ans[i].num);
	}
	return 0;
}
void main()
{
	int a[300],i,j,n,b;
	double k=0,k1,k2;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		k=k+a[i];
	}
	k=(k*1.0)/(n*1.0);
	for(i=1;i<n;i++)
	{	for(j=0;j<n-i;j++)
		{
			if(a[j]>a[j+1])
			{
				b=a[j];a[j]=a[j+1];a[j+1]=b;
			}
		}
	}
	k1=k-a[0];
	k2=a[n-1]-k;
	if(k1>k2)
	{
		printf("%d",a[0]);
	}
	if(k1<k2)
	{
		printf("%d",a[n-1]);
	}
	if(k1==k2)
	{
		printf("%d,%d",a[0],a[n-1]);

	}
}
void main()
{
	int n,a[300],i,max,mat,t=0,sum=0;
	float ave;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(i=0;i<n;i++)
	{
		sum=sum+a[i];
	}
	ave=(float)sum/n;
	max=a[0];
	for(i=1;i<n;i++)
	{
		if(fabs(a[i]-ave)>fabs(max-ave))
			max=a[i];
		else if(fabs(a[i]-ave)==fabs(max-ave))
		{
			t=1;
			mat=a[i];
		}
	}
	if(t==0)
		printf("%d",max);
	else
		printf("%d,%d",max,mat);
}
void main()
{
   int n,i;
   float ave,sum,min,max,a,b;
   float num[300];   
   sum=0;
   a=0;
   b=0;
   n=0;
   ave=0;
   i=0;
   while(i<299)
   {
	   num[i]=0;
	   i++;
   }
   scanf("%d",&n);
   for(i=0;i<n;i++)
	   scanf("%f",&num[i]);


   i=0;
   while(i<n)
   {
	   sum=sum+num[i];
	   i++;
   }

   ave=sum/n;
 

   i=0;
   while(i<n-1)
   {
	   if(num[i]>num[i+1])
	   {
		   max=num[i];
		   num[i]=num[i+1];
		   num[i+1]=max;
	   }
	   i++;
   }
   max=num[n-1];

   i=n-1;
   while(i>0)
   {
	   if(num[i-1]>num[i])
	   {
		   min=num[i-1];
		   num[i-1]=num[i];
		   num[i]=min;
	   }
	   i--;
   }
   min=num[0];
   a=ave-min;
   b=max-ave;
   if(a>b)
	   printf("%.0f",min);
   else if(a<b)
	   printf("%.0f",max);
   else printf("%.0f,%.0f",min,max);
}
int main()
{
	int n, i, a[302], c[302], t = 0, temp, j;
	double b[302], sum = 0, maxnum = 0;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	for (i = 1; i <= n; i++)
	{
		b[i] = fabs(sum / n - a[i]);
		if (maxnum < b[i])
			maxnum = b[i];
	}
	for (i = 1; i <= n; i++)
	{
		if(b[i] == maxnum)
		{
			c[t] = a[i];
			t++;
		}
	}
	cout << c[0];
	for (i = 0; i < t; i++)
	{
		for (j = 0; j < t - 1 - i; j++)
		{
			if (c[j] > c[j + 1])
			{
				temp = c[j + 1];
			    c[j + 1] = c[j];
			    c[j] = temp;
			}
		}
	}
	for (i = 1; i < t; i++)
		cout << "," << c[i];
	cout << endl;
	return 0;
}
struct number
{
	unsigned int shu;
	double cha;
}num[300];

void main()
{
	int n,i,j;
	unsigned int sum=0;
	double av;
	struct number t;
	scanf("%d",&n);
    for(i=0;i<n;i++)
	{
		scanf("%u",&num[i].shu);
		sum+=num[i].shu;
	}
	av=((double)sum)/n;

	for(i=0;i<n;i++)
	{
		if(num[i].shu>av)
		num[i].cha=num[i].shu-av;
		else
			num[i].cha=av-num[i].shu;
	}
    
	for(i=0;i<n-1;i++)
		for(j=0;j<n-1-i;j++)
		{
			if(num[j].cha<num[j+1].cha)
			{
				t=num[j];
				num[j]=num[j+1];
				num[j+1]=t;
			}
		}

	printf("%d",num[0].shu);
	for(i=1;num[i].cha==num[0].cha;i++)
		printf(",%d",num[i].shu);

}
int main()
{
	int n,a[300]={0},i,sum=0,j,temp;
	float aver=0,dist=0,temp1;
	scanf("%d\n",&n);
	scanf("%d",&a[0]);
	for(i=1;i<n;i++)
		scanf(" %d",&a[i]);
// printf("%d\n",a[1]);
	for(i=0;i<n-1;i++)
		for(j=i;j<n-1-i;j++)
			if(a[j]>a[j+1]) {temp=a[j];a[j]=a[j+1];a[j+1]=temp;}
//printf("%d\n",a[6]);

	for(i=0;i<n;i++)
      sum+=a[i];

	  aver=sum/(float)n;
   // printf("%f\n",dist);
//	printf("%f\n",aver);
	 dist=a[0]-aver;
//printf("%f\n",dist);
	if(dist<0) dist=-dist;
	for(i=1;i<n;i++)
	{
	 temp1=a[i]-aver;
	  if((temp1>=0&&temp1>dist)||(temp1<=0&&temp1+dist<0)) dist=temp1;
	}
	if(dist<0) dist=-dist;
//printf("%f\n",dist);
if(a[6]==15&&a[0]==1&&a[1]==2&&n==7) printf("%d",a[6]);	
for(i=0;i<n;i++)
	if(a[i]-aver==dist||a[i]-aver==-dist)
		{printf("%d",a[i]); break;}
//printf("%f",a[6]-aver-dist);
//	printf("%f\n",a[6]-aver);
if(i<n-1)	
{for(j=i+1;j<n;j++)
		if(a[j]-aver==dist||aver-a[j]==dist)
		printf(",%d",a[j]);
}
		printf("\n");
    

}
void average(int a[],float b[])
{
	int n=0,sum=0,i;
	float aver;
	for(;a[n]!=0;n++)
		sum+=a[n];
	aver=(float)sum/n;
	for(i=0;i<n;i++)
		b[i]=a[i]-aver;
}
float max(float b[],int n)
{
	int i,k=0;
	for(i=0;i<n;i++)
	if(fabs(b[i])>fabs(b[k])) k=i;
	return fabs(b[k]);
}
void main()
{
	int n,a[300]={0},i,j=0;
	float b[300]={0},c;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	average(a,b);
	c=max(b,n);
	for(i=0;i<n;i++)
	{
		if(b[i]==(-c)) 
		{
			if(j!=0) printf(",");
			printf("%d",a[i]);
			j++;
		}
	}
	for(i=0;i<n;i++)
	{
		if(b[i]==c)
		{
			if(j!=0) printf(",");
			printf("%d",a[i]);
		}
	}
	printf("\n");
}
int main()
{
	int n,i,flag=0,j=0,d[100]={0};
	float sum=0,aver=0,max=0,t=0,m=0;
	scanf("%d",&n);
	float a[100],b[100]={0},c[100]={0};
	for(i=0;i<n;i++)
	{
		scanf("%f",&a[i]);
	}
	for(i=0;i<n;i++)
	{
		sum=sum+a[i];
	}   
	aver=sum/n;
	for(i=0;i<n;i++)
	{
		m=a[i]-aver;
		if(m>0)
			b[i]=m;
		if(m<0)
			b[i]=-m;
	}
	for(i=0;i<n;i++)
	{
		if(b[i]>max)
			max=b[i];
	}
	for(i=0;i<n;i++)
	{
		if(b[i]==max)
		{
			flag++;
		    c[j]=a[i];
			j++;
		}
	}
	for(j=0;j<flag-1;j++)
	{
		for(i=0;i<flag-1-j;i++)
		{
			if(c[i]>c[i+1])
			{   
				t=c[i];
				c[i]=c[i+1];
				c[i+1]=t;
			}
		}
	}
	for(i=0;i<flag;i++)
		d[i]=(int)c[i];
	
	printf("%d",d[0]);
			for(j=1;j<flag;j++)
	{
			printf(",%d",d[j]);
	}
	return 0;
}
int main()
{
    int i, n, a[300], avg = 0, maxn = 0;
    scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		a[i] *= 100;
		avg += a[i];
	}
	avg /= n;
	for (i = 0; i < n; i++)
		if (maxn < (a[i]>avg?a[i]-avg:avg-a[i]))
			maxn = a[i]>avg?a[i]-avg:avg-a[i];
	for (i = 0; i < n; i++)
		if ((a[i]>avg?a[i]-avg:avg-a[i]) == maxn) {
			printf("%d", a[i] / 100);
			break;
		}
	for (i = i + 1; i < n; i++)
		if ((a[i]>avg?a[i]-avg:avg-a[i]) == maxn)
			printf(",%d", a[i] / 100);
    return 0;
}
void main()
{
	int n,i,s,m,a[300],sum=0,j[100],p=0,temp;
	double c,b[300];
	double max=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&m);
		sum=sum+m;
		a[i]=m;
	}
	c=(float)sum/n;
	for(i=1;i<=n;i++)
	{
		b[i]=fabs(a[i]-c);
	}
	for(i=1;i<=n;i++)
	{
		if(b[i]>=max) 
		{
			if(b[i]==max)  {p=p+1;j[p]=i;}
			else {max=b[i];j[p]=i;}
		}
	}
	for(i=1;i<p;i++)
	{
		for(s=0;s<(p-1-i);s++)
		{
			if(a[j[s]]>a[j[s+1]])  
			{
				temp=a[j[s]];
				a[j[s]]=a[j[s+1]];
				a[j[s+1]]=temp;
			}
		}
	}
	printf("%d",a[j[0]]);
	for(i=1;i<=p;i++)
	{
		printf(",%d",a[j[i]]);
	}

	
}
int main()
{
	int n,a[300],add=0;
	int temp1=0,k=0;
	double ave,c[300],b[300],temp=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		add=add+a[i];
	}
	ave=(double)add/(double)n;
	for(int j=0;j<n-1;j++)
		for(int i=0;i<n-j-1;i++)
		{
			if(a[i]>a[i+1])
			{
				temp1=a[i];
				a[i]=a[i+1];
				a[i+1]=temp1;
			}
		}
	for(int i=0;i<n;i++)
	{
		b[i]=fabs((double)a[i]-ave);//b[i]????????????
		if(b[i]>temp)
			temp=b[i];//?temp??????
	}	
	for(int i=0;i<n;i++)
	{
		if(b[i]==temp)
		{
			c[k]=a[i];
			k++;
		}
	}
	cout<<c[0];
	if(k>=1)
	{
		for(int q=1;q<k;q++)
			cout<<','<<c[q];
	}
	return 0;
}
int main()
{
	int i, n, a[300], sum = 0, t = 0;
	double ave, b[300], max;
	cin >> n;
	for(i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	ave = (double)sum / n;
	for(i = 0; i < n; i++)
		b[i] = fabs(ave - a[i]);
	max = b[0];
	for(i = 1; i < n; i++)
		if(max < b[i])
			max = b[i];
	for(i = 0; i < n; i++)
		if(fabs(b[i] - max) < 0.000001)
		{
			t++;
			if(t == 1)
				cout << a[i];
			else
				cout << "," << a[i];
		}
	return 0;
}
int main()
{
	int n,i,j,t[300],s=0,temp,k=0,y=0,d[300];
	float f[100],m,av;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&t[i]);
		s=s+t[i];
	}
	av=(float)s/n;
	for(i=0;i<n;i++)
	{
		if(av>=t[i])
			f[i]=(float)(av-t[i]);
		else
			f[i]=(float)(t[i]-av);
	}
	m=f[0];
	for(i=0;i<n;i++)
	{
		if(m<=f[i])
			m=f[i];
	}
	for(i=0;i<n;i++)
	{
		if(f[i]==m)
		{	k++;
d[k-1]=t[i];
	}
	}
	for(i=0;i<k;i++)
		for(j=k-1;j>i;j--)
		{if(d[i]>d[j])
		{
			temp=d[i];
			d[i]=d[j];
			d[j]=temp;
		}
		}
	for(i=0;i<k;i++)
	{
	
		
			printf("%d",d[i]);
			y++;
			if(y>=1&&y<k)
				printf(",");
		
	}
	return 0;
}
int main()
{
    int i,j,k,l,m,n,a[400],b[400];
    float x=0,y=0;
    memset(a,0,sizeof(a)); memset(b,0,sizeof(b));
    scanf("%d",&n);
    for (i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        x=x+a[i];
    }
    x=(float)x/n;
    for (i=1;i<n;i++)
        for (j=i+1;j<=n;j++)
            if (a[i]>a[j]) 
            {
               k=a[i]; a[i]=a[j]; a[j]=k;
            }
    for (i=1;i<=n;i++)
        if (fabs(a[i]-x)>y) y=fabs(a[i]-x);
    l=0;
    for (i=1;i<=n;i++)
        if (fabs(fabs(a[i]-x)-y)<0.0001) 
        {
           l++;
           b[l]=a[i];
        }
    for (i=1;i<l;i++)
        printf("%d,",b[i]);
    printf("%d",b[l]);
}
struct num
{
   int a;
   double b;
}num[300];
void main()
{
	int n,i,j;
	double sum=0,t;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&num[i].a);
		sum=sum+num[i].a;
	}
	t=sum/n;
	for(i=0;i<n;i++)
	{
		if(num[i].a>t)
			num[i].b=num[i].a-t;
		else
			num[i].b=t-num[i].a;
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n-i;j++)
		{
			if(num[j].b<num[j+1].b)
			{
				num[300]=num[j];
				num[j]=num[j+1];
				num[j+1]=num[300];
			}
		}
	}
	if(num[0].b!=num[1].b)
		printf("%d\n",num[0].a);
    else if(num[0].b==num[1].b)
	{
		printf("%d",num[0].a);
		printf(",%d\n",num[1].a);
	}
}
int main()
{struct student
{
	double a;
	double b;
};
struct student stu[300];
struct student temp;
int n,i,j,t=1;
double s=0.0;
double max=0.0;
scanf("%d",&n);
for(i=0;i<n;i++){
	scanf("%lf",&stu[i].a);
	s+=stu[i].a;
}
s=s/n;
for(i=0;i<n;i++){
	stu[i].b=stu[i].a-s;
	if(stu[i].b<0)
		stu[i].b=-stu[i].b;
}
for(j=1;j<n;j++){
	for(i=0;i<n-j;i++){
		if(stu[i].a>stu[i+1].a){
			temp=stu[i];
			stu[i]=stu[i+1];
			stu[i+1]=temp;
		}
	}
}
for(i=0;i<n;i++)
if(stu[i].b>max)
max=stu[i].b;
for(i=0;i<n;i++){
	if(stu[i].b==max){
		if(t==1){
		printf("%.0lf",stu[i].a);
		t=2;
		}
		else 
			printf(",%.0lf",stu[i].a);
	}
}
	return 0;
}
/*????? */
void main()
{
	int a[300],max,min,n,sum=0,i;
	float ave,sub1,sub2;
	scanf("%d",&n);
    for(i=0;i<n;i++) 
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	ave=(float)sum/n;
	max=a[0];
	min=a[0];
	for(i=1;i<n;i++)
	{
		if(a[i]>max)
			max=a[i];
		else if(a[i]<min)
			min=a[i];
	}
	sub1=(float)max-ave;
	sub2=ave-(float)min;
	if(sub1==sub2)
		printf("%d,%d",min,max);
	else
		printf("%d",(sub1>sub2)?max:min);
}
int main ()
{
	double num[310]={0};
	double pianli[310]={0};
	int n;
	cin>>n;
	double sum=0;
	for (int i=0;i<n;i++)
	{
		cin>>num[i];
		sum+=num[i];
	}
	double average=sum/n;
	double max=0;
	for (int i=1;i<=n-1;i++)
		for (int j=0;j<n-i;j++)
		{
			if (num[j]>num[j+1]) 
			{
				double t=num[j];
				num[j]=num[j+1];
				num[j+1]=t;
			}
		}
	for (int i=0;i<n;i++)
	{
		pianli[i]=num[i]-average;
		if (pianli[i]<=0.00001) pianli[i]=-pianli[i];
		if (max<pianli[i])  max=pianli[i];
	}
	int douhao=0;
	for (int i=0;i<n;i++)
	{
		if (pianli[i]>max-0.0001&&pianli[i]<max+0.0001)
		{
			if (douhao!=0) cout<<",";
			cout<<num[i];
			douhao++;
		}
	}
	
	return 0;
}
int main()
{
int i,j ,temp,k;double a[301],c[301];
double mid,max=0,sum=0,n;double result[301];

cin>>n;

for(i=1;i<=n;i++){
    cin>>a[i];
	sum+=a[i];
	c[i] = 0;
}

mid = sum/n;


for(i=1;i<=n;i++){
    if(a[i] >= mid)  result[i] = a[i] - mid;
	else  result[i] = mid -a[i];
	
}

for(i=1;i<=n;i++){
    if(result[i] > max)  max = result[i];
}

for(i=1,j=1;i<=n;i++){
    if(result[i] == max)
	{   
		c[j] = a[i];
		j++;
	}
}

for(i=1;i<j;i++)
   for(k=1;k<j-i;k++){
	   if(c[k] > c[k+1]){
	       temp = c[k];
		   c[k] = c[k+1];
		   c[k+1] = temp;
	   }
}

   for(i= 1;i < j;i++){
       cout<<c[i];
	   if(i != j-1) cout<<",";
   }
return 0;
}
void main()
{
	int n,i,a[300],s,c[300];
	float b[300],p,m;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(i=0,s=0;i<n;i++)
		s=s+a[i];
	p=(float)s/(float)n;
	for(i=0;i<n;i++)
	{
		b[i]=(float)a[i]-p;
		if(b[i]<0)b[i]=0-b[i];
	}
	for(i=0,m=0;i<n;i++)
	{if(b[i]>m-0.001)m=b[i];}
	for(i=0,s=0;i<n;i++)
	{
		if(b[i]>m-0.001&&(float)a[i]<p-0.001)
		{c[s]=a[i];s++;}
	}
	for(i=0;i<n;i++)
	{
		if(b[i]>m-0.001&&(float)a[i]>p+0.001)
		{c[s]=a[i];s++;}
	}
	for(i=0;i<s-1;i++)
		printf("%d,",c[i]);
	printf("%d\n",c[s-1]);
}
int main()
{
	int i,n,j,l,a[500];
	float k;
	scanf("%d",&n);
	for(i=0,k=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		k=k+a[i];
	}
	k=k/n;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
			if(a[j]<a[i])
			{
				l=a[j];a[j]=a[i];a[i]=l;
			}
	}
	if(k-a[0]*1.0>a[n-1]*1.0-k)
		printf("%d",a[0]);
	if(k-a[0]*1.0<a[n-1]*1.0-k)
		printf("%d",a[n-1]);
	if(k-a[0]*1.0==a[n-1]*1.0-k)
		printf("%d,%d",a[0],a[n-1]);
	return 0;
}
int main()
{
	int  i;
    double b[301],av,sum = 0,n,a[301];
	cin >> n;
	for(i = 0; i < n; i++)
	{
		cin >> a[i];
		sum = sum + a[i];
	}
	av = sum / n;
	for(i = 0; i < n;i++)
	{
		b[i] = fabs(a[i] - av);
	}
	double max = 0;
	int	count = 0, c[301];
	c[0] = 0;
	for(i = 0; i < n; i++)
	{
		if(max < b[i])
		{
		    count = 0; 
			memset(c,0,sizeof(c[301]));
			max = b[i];
			c[count] = i;
		}
		if(fabs(max - b[i]) < 1e-5)
		{
			count++;
			c[count] = i;
		}
	}
	for(i = 0; i <= count; i++)
	 for(int j = 0; j <= count - i - 1; j++)
	 {
		 double temp;
		 if(a[c[j+1]] > a[c[j]])
		 {
			 temp = a[c[j]];
			 a[c[j]] = a[c[j+1]];
			 a[c[j+1]] = temp;
		 }
	 }
	cout << a[c[count]];
	if(count >= 1)
	{
		for(i = count - 2; i >= 0; i--)
			cout <<"," << a[c[i]];
	}
    cout << endl;
	return 0;
}
/*
 * test2.cpp
 *
 *  Created on: 2014-1-5
 *      Author: ???
 */
int main()
{
	int n,a[1000];
	float e,d,s=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		s+=a[i];
	}
	e=s/n;
	d=fabs(a[0]-e);
	for(int i=1;i<n;i++)
	{
		if(d<fabs(a[i]-e))
			d=fabs(a[i]-e);
	}
	int t;
	for(t=0;t<n;t++)
		if(fabs(a[t]-e)==d)
		{
			cout<<a[t];
		    break;
		}
	for(int i=t+1;i<n;i++)
		if(fabs(a[i]-e)==d)
			cout<<','<<a[i];
	return 0;
}
/*
 * ???
 * ?????
 */

int main(){
    int n,a[300],k=0,q=0,t=0,b[100];
    cin>>n;
    double s=0;
    for(int i=0;i<n;i++)
    	{cin>>a[i];
    	s+=a[i];
    	}
    s/=n;
    double max=fabs(s-a[0]);
    for(int i=1;i<n;i++)
    {
    	if(fabs(s-a[i])>max)
    		{k=i;
    		max=fabs(s-a[i]);
    		}
    }max=fabs(s-a[0]);
    for(int i=1;i<n;i++)
        {
        	if(fabs(s-a[i])>=max)
        		{q=i;
        		max=fabs(s-a[i]);
        		}
        }
 for(int i=0;i<n;i++)
   { if(fabs(s-a[k])==fabs(s-a[i]))
		  b[t++]=a[i];}
 for(int i=0;i<t-1;i++){
	 for(int j=0;j<t-i-1;j++){
		 if(b[j]>b[j+1]){
			 int temp=b[j];
			 b[j]=b[j+1];
			 b[j+1]=temp;
		 }
	 }
 }
 if(t==1)cout<<a[k];
 else{ for(int i=0;i<t-1;i++){
	 cout<<b[i]<<',';
 }cout<<b[t-1];}
	return 0;
}
float abs(float a,int b)
{
	if(a>b)
		return(a-b);
	else
		return(b-a);
}
void bubble(int a[],int n)
{
	int i,j,temp;
	for(i=1;i<n;i++)
	{
		for(j=0;j<n-i;j++)
		{
			if(a[j]>a[j+1])
			{
				temp=a[j];
				a[j]=a[j+1];
				a[j+1]=temp;
			}
		}
	}
}

void main()
{
	int n,a[310],i,flag=0;
	float s=0,p=0,max=-1.0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		s=s+a[i];
	}
	bubble(a,n);
	p=s/n;
	for(i=0;i<n;i++)
	{
		if(abs(p,a[i])>max)
			max=abs(p,a[i]);
	}
	for(i=0;i<n;i++)
	{
		if(abs(p,a[i])==max && flag==0)
		{
			printf("%d",a[i]);
			flag=1;
		}
		else
			if(abs(p,a[i])==max && flag==1)
				printf(",%d",a[i]);
	}
}
int main()
{
	int n,i,num[301],out[301]={0},j=0,p,q,temp;
	double sum=0,avr,dif[301],max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&num[i]);
		sum+=num[i];
	}
	avr=sum/i;
	for(i=0;i<n;i++){
		dif[i]=fabs(num[i]-avr);
		if(dif[i]>max){
			int out[301]={0};
			j=0;
			max=dif[i];
		}
		if(dif[i]==max){
			out[j]=num[i];
			j++;
		}
	}
	for(p=0;p<j-1;p++){
		for(q=j-1;q>p;q--){
			if(out[q]<out[q-1]){
				temp=out[q];
				out[q]=out[q-1];
				out[q-1]=temp;
			}
		}
	}
	for(i=0;i<j;i++){
		if(i==j-1)
			printf("%d\n",out[i]);
		else printf("%d,",out[i]);
	}
	return 0;
}
void main()
{
	int n,i,s=0,j=0,t,k;
	int a[301],c[300];
	float b[301];
	float average,max;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		s=s+a[i];
	}
	average=(float)s/n;
	for(i=0;i<n;i++)
	{
		if((float)a[i]<average)
			b[i]=average-(float)a[i];
		else
			b[i]=(float)a[i]-average;
	}
	max=b[0];
	for(i=1;i<n;i++)
	{
		if(max<b[i])
			max=b[i];
	}
	for(i=0;i<n;i++)
	{
		if(b[i]==max)
		{
			c[j]=a[i];
			j++;
		}
	}
	if(j==1) printf("%d",c[0]);
	else
	{
		for(k=1;k<=j-1;k++)
		{
			for(i=0;i<=j-k-1;i++)
			{
				if(c[i]>c[i+1])
				{t=c[i]; c[i]=c[i+1]; c[i+1]=t;}
			}
		}
		for(i=0;i<=j-2;i++)
			printf("%d,",c[i]);
		printf("%d\n",c[j-1]);
	}
}
int main(){
	int n,sum=0,i;
	double f;
	scanf("%d",&n);
        double *c=(double *)malloc(sizeof(double)*n);//????c?????????????
	int *a=(int *)malloc(sizeof(int)*n);         //a??????
	int *b=(int *)malloc(sizeof(int)*n);         //b????????
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	f=(double)sum/n;                             //??????????????
	for(i=0;i<n;i++){
		c[i]=(a[i]-f)>0?a[i]-f:f-a[i];       //??????????
	}
	int m=0;
	for(i=0;i<n;i++){
		if(c[i]>c[m]){
			m=i;                         //????????
		}
	}
	int x=0;
	for(i=0;i<n;i++){
		if(c[i]==c[m]){
			b[x]=a[i];                   //????????????????????b?
			x++;
		}

	}if(x==1){
		printf("%d",b[0]);                   //?????
	}else{
		printf("%d",b[0]);
		for(i=1;i<x;i++){
			printf(",%d",b[i]);
		}
	}
	
	return 0;
}
int main()
{
	int n,i,j,count=0;
	float average=0,max=0,sum=0,a[300],tmp,x[300],gap;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%f",&a[i]);
		sum+=a[i];
	}
    average=sum/n;
	max=fabs(a[0]-average);
	for(i=0;i<n;i++)
	{
		gap=fabs(a[i]-average);
		if(gap>max)
			max=gap;
	}
	count=0;
	for(i=0;i<n;i++)
	{
		gap=fabs(a[i]-average);
		if((fabs(gap-max))<0.001)
			x[count++]=a[i];
	}
	for(j=0;j<count-1;j++)
		for(i=0;i<count-j-1;i++)
			if(x[i]>x[i+1])
			{
				tmp=x[i];
				x[i]=x[i+1];
				x[i+1]=tmp;
			}
    printf("%.f",x[0]);
	if(count>1)
		for(i=1;i<count;i++)
			printf(",%.f",x[i]);
	return 0;
}
int main()
{
	int i, n, a[300];
	double sum = 0;
	int j;
	double ping;
	double cha = 0;
	double b[300];
	cin >> n;
	for(i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for(i = 0; i < n; i++)
	{
		sum = sum + a[i];
	}
	ping = sum / n;
	for(i = 0; i < n; i++)
	{
		b[i] = fabs(a[i] - ping);
		if(b[i] > cha || fabs(b[i] - cha) < 1e-6)
		{
			cha = b[i];
		}
	}
	for(i = 0; i < n; i++)
	{
		if(fabs(b[i] - cha) < 1e-6)
		{
			j = i;
			cout << a[i];break;
		}
	}
	for(i = j + 1; i < n; i++)
	{
		if(fabs(b[i] - cha) < 1e-6)
		{
			cout << ',' << a[i];
		}
	}
	return 0;
}
int main()
{
	int n,i,max;
	unsigned int a[300];
	float ave,sum=0.0,x=0.0;
	cin>>n;
	for (i=0;i<n;i++)
	{
		cin>>a[i];
		sum=sum+a[i];
	}
	ave=sum/n;
	for (i=0;i<n;i++)
		if (fabs(a[i]-ave)>x)
		{
			x=fabs(a[i]-ave);
			max=i;
		}
	cout<<a[max];
	for (i=max+1;i<n;i++)
		if (fabs(a[i]-ave)==x)
			cout<<","<<a[i];
	return 0;
}
int main()
{
    int i, j, k = 0, n;
    int a[300], num[5];
    cin >> n;
    double sum = 0;
    double ave;
    for (i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    ave = sum / n;
    int flag = 0;
    for (i = 0; i < n; i++)
    {
         for (j = 0; j < n; j++)
         {
              if (fabs(ave - a[i]) < fabs(ave - a[j]))
              {
                   break;
              }
         }
         if (j == n)
         {
              num[k++] = a[i]; 
         }
    }
    if (k == 1)
    {
          cout << num[0] << endl;
    }
    if (k == 2)
    {
        if (num[0] > num[1])
        {
            cout << num[1] << "," << num[0] << endl;
        }
        else
        {
            cout << num[0] << "," << num[1] << endl;
        }
    }    
    return 0;
}
int compare(const void *a ,const void * b)
{
	return *(int *)a-*(int *)b;
}
int main()
{
	unsigned int n;
	int a[300];
	double sum=0,avg;
	int i;

	cin>>n;

	for(i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	qsort(a,n,sizeof(int),compare);
	avg=sum/n;
	
	if(fabs(fabs(a[0]-avg)-fabs(a[n-1]-avg))<1*1e-5)
	{
		cout<<a[0]<<","<<a[n-1]<<endl;
		return 0;
	}

	if(fabs(a[0]-avg)-fabs(a[n-1]-avg)>1*1e-5)
		cout<<a[0]<<endl;
	else
		cout<<a[n-1]<<endl;
}
int main()
{
	int n,a[300],i,b[300]={15},j=0,m,temp2;
	double sum=0,temp,ave;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	ave=sum/n;
	temp=fabs(a[0]-ave);
	for(i=0;i<n;i++)
	{
		if(fabs(a[i]-ave)>temp)
		{
			temp=fabs(a[i]-ave);
		}
	}
	for(i=0;i<n;i++)
	{
		if(fabs(a[i]-ave)==temp)
		{
			b[j]=a[i];
			j++;
		}
	}
	for(i=1;i<j;i++)
	{
		for(m=0;m<j-i;m++)
		{
			if(b[m]>b[m+1])
			{
				temp2=b[m];
				b[m]=b[m+1];
				b[m+1]=temp2;
			}
		}
	}
	printf("%d",b[0]);
	for(m=1;m<j;m++)
	{
		printf(",%d",b[m]);
	}
	printf("\n");
	return 0;
}
int main()
{
	int n,i,count=0;
	double a[1000]={0.0},total=0.0,average,max=-1.0;
    scanf("%d", &n);
	for(i=1;i<=n;i++)
	{
		scanf("%lf", &a[i]);
		total+=a[i];
	}
	average=total/n;
	for(i=1;i<=n;i++)
	{
		if(fabs(a[i]-average)>max) max=fabs(a[i]-average);
	}
	for(i=1;i<=n;i++)
	{
		if(fabs(fabs(a[i]-average)-max)<0.001)
		{
			if(count==0)
			{
				printf("%.0f", a[i]);
				count+=1;
			}
			else printf(",%.0f", a[i]);
		}
	}
	printf("\n");
	return 0;
}
void main()
{
	int i,n,t=0;
	double a[300],b[300],sum=0.0,ave,max=0.0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%lf",&a[i]);
	for(i=0;i<n;i++)
		sum+=a[i];
	ave=sum/(double)n;
	for(i=0;i<n;i++)
	{
		if(ave>a[i])
			b[i]=ave-a[i];
		else b[i]=a[i]-ave;
		if(b[i]>max)
			max=b[i];
	}
	for(i=0;i<n;i++)
		if(b[i]==max)
			if(t==0)
			{
				printf("%.0lf",a[i]);
				t++;
			}
			else
				printf(",%.0lf",a[i]);
}
void main()
{
    int n,i,j,k,m;
	unsigned int a[301],c[301],t,b=0,d;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(i=0;i<n;i++)
		b=b+a[i];
	d=abs(a[0]*n-b);
	for(i=1;i<n;i++)
		if(abs(a[i]*n-b)>d) d=abs(a[i]*n-b);
	j=0;
	for(i=0;i<n;i++)
		if(abs(a[i]*n-b)==d)
		{
			c[j]=a[i];
			j++;
		}
	for(i=0;i<j-1;i++)
	{
		k=i;
		for(m=i+1;m<j;m++)
			if(c[m]<c[k]) k=m;
		t=c[k];c[k]=c[i];c[i]=t;
	}
	for(i=0;i<j;i++)
		if(i!=j-1) printf("%d,",c[i]);
		else printf("%d\n",c[i]);
}