semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
void main()
{
	int n,sum=0,max=0;
	int i,j,t,a[400];
	float f,f1,f2;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	f=(double)sum/n;
	for(i=0;i<n-1;i++)
	  for(j=0;j<n-1-i;j++)
		  if(a[j]>a[j+1])
		  {
			  t=a[j];
			  a[j]=a[j+1];
			  a[j+1]=t;
		  }
		  f1=(double)a[0];
		  f2=(double)a[n-1];

		  if(fabs(f-f1)==fabs(f-f2))
			  printf("%d,%d",a[0],a[n-1]);
		  else if(fabs(f-f1)>fabs(f-f2))
			  printf("%d",a[0]);
		  else
			  printf("%d",a[n-1]);
}
void main()
{
	int i,n,l=0;
	int a[400];
	double max=0,s=0,p,b[400];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(i=0;i<n;i++)
		s+=a[i];
	p=s/n;
	for(i=0;i<n;i++){
		if(a[i]>p) b[i]=a[i]-p;
		else b[i]=p-a[i];
		if(b[i]>max) max=b[i];
	}
	for(i=0;i<n;i++)
		if(b[i]==max){
			if(l!=0)
				printf(",%d",a[i]);
			else{
				printf("%d",a[i]);l+=1;}
		}
}
int main()
{
int n, i,shu[300],he=0,j;
double a;
scanf ("%d", &n);
for (i=0; i<n; i++)
	{
scanf ("%d", &shu[i]);
he=he+shu[i];}
a = (double)he / n;
for (i=0;i<n;i++)
{ for (j=n-1;j>=1;j--)
{ int t;
if (shu[j-1]>shu[j]){
t = shu[j-1];
shu[j-1]=shu[j];
shu[j]=t;}
}
}
if ((a-shu[0])>(shu[n-1]-a))
printf ("%d", shu[0]);
else if ((a-shu[0])<(shu[n-1]-a))
printf ("%d", shu[n-1]);
else if ((a-shu[0])==(shu[n-1]-a)&&shu[0]!=shu[n-1])
printf ("%d,%d", shu[0], shu[n-1]);
return 0;
}
void main()
{
	int  n,i,a[300],k,num=0;
	double ave,b[300],sum=0,max=0;
	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++)
	{
		b[i]=fabs(a[i]-ave);
		if(b[i]>max)
		{
			max=b[i];
		}
	}
	for(i=0;i<n;i++)
	{
		if(b[i]==max)
		{
			num++;
			if(num==1)
				printf("%d",a[i]);
			else
				printf(",%d",a[i]);
		}
	}
	printf("\n");
}
int main()
{
	int n,i,t,j,x[300],s[300],k=0;
	double a,y[300],sum=0,b=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&x[i]);
		sum+=x[i];
	}
	a=sum/n;
	for(i=0;i<n;i++)
	{
		if(x[i]>a){y[i]=x[i]-a;}
		if(x[i]<a){y[i]=a-x[i];}
	}
	for(i=0;i<n;i++)
	{
		if(y[i]>b){b=y[i];}
	}
	for(i=0;i<n;i++)
	{
		if(y[i]==b){
			s[k]=x[i];
			k=k+1;
		}
	}
    for(i=0;i<k;i++)
	{
		for(j=k-1;j>i;j--)
		{
			if(s[j]<s[j-1])
			{
				t=s[j];
				s[j]=s[j-1];
				s[j-1]=t;
			}
		}
	}
	for(i=0;i<k-1;i++)
	{
		printf("%d,",s[i]);
	}
	printf("%d",s[k-1]);

	
	return 0;
}
void main()
{
	unsigned int n,a[300],i,sum=0,max,min;
	float m;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	m=(float)sum/n;
	max=a[0];
	min=a[0];
	for(i=0;i<n;i++)
	{
		if(max<a[i])
			max=a[i];
		if(min>a[i])
			min=a[i];
	}
	if(((float)max-m)>(m-(float)min))
		printf("%d",max);
	else if(((float)max-m)<(m-(float)min))
		printf("%d",min);
	else if(((float)max-m)==(m-(float)min))
		printf("%d,%d",min,max);
}
void main()
{
	double a[300],sum=0,max=0,t;int i,j,n,jud=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%lf",&a[i]),sum+=a[i];
	sum/=n;
	for(i=0;i<n;i++)if(fabs(sum-a[i])>max)max=fabs(sum-a[i]);
	for(i=1;i<n;i++)for(j=0;j<n-i;j++)if(a[j]>a[j+1])t=a[j],a[j]=a[j+1],a[j+1]=t;
	for(i=0;i<n;i++)if(fabs(fabs(sum-a[i])-max)<=0.0001)
	{
		if(jud==0)jud=1,printf("%g",a[i]);
		else printf(",%g",a[i]);
	}
}
int main()
{
    int n,s=0,i,j,a[1000],maxm=-1,minm=2147483647;
    cin>>n;
    for(i=1;i<=n;i++)
    {
                       cin>>a[i];
                       s+=a[i];
                       if(a[i]>maxm)maxm=a[i];
                       if(a[i]<minm)minm=a[i];
    }
    int s1=minm*n,s2=maxm*n;
    if(s2-s>s-s1)
    cout<<maxm;
    if(s2-s<s-s1)
    cout<<minm;
    if(s2-s==s-s1)
    cout<<minm<<","<<maxm<<endl;
    return 0;
}
int main()
{
    int n,a[300],b[300],i,j,c=0,t;
    float aver=0,d=0;
    scanf("%d",&n);
    for(i=0;i<n;i++) {scanf("%d",&a[i]); aver+=a[i];}
    aver=aver/n;
    
    
    for(i=0;i<n;i++) if((a[i]-aver>0?a[i]-aver:aver-a[i])>d) d=a[i]-aver>0?a[i]-aver:aver-a[i];
    
   
    
    for(i=0;i<n;i++) if((a[i]-aver>0?a[i]-aver:aver-a[i])==d) b[c++]=a[i];
    
    
    for(i=0;i<c;i++)
    for(j=i+1;j<c;j++) if(b[i]>b[j]) {t=b[i]; b[i]=b[j];b[j]=t;}
    
    for(i=0;i<c-1;i++) printf("%d,",b[i]); 
    printf("%d",b[c-1]);
}
void main()
{
	int n,sum,a,i,min,max,ci,ca;
	float ave;
	scanf("%d",&n);
	scanf("%d",&a);
	min=max=sum=a;
	ci=ca=1;
	for(i=1;i<n;i++)
	{
		scanf("%d",&a);
		if(a>max)
		{
			max=a;
			ca=1;
		}
		else if(a==max)
			ca++;
		if(a<min)
		{
			min=a;
			ci=1;
		}
		else if(a==min)
            ci++;
		sum=sum+a;
	}
	ave=(float)sum/n;
	if(2*ave>(max+min))
	{
		for(i=0;i<ci-1;i++)
			printf("%d,",min);
		printf("%d\n",min);
	}
	else if(2*ave<(max+min))
	{
		for(i=0;i<ca-1;i++)
			printf("%d,",max);
		printf("%d\n",max);
	}
	else
	{
		for(i=0;i<ci;i++)
			printf("%d,",min);
		for(i=0;i<ca-1;i++)
			printf("%d,",max);
		printf("%d\n",max);
	}
}
main()
{
	int n,i,s=0,w;
	float p,q;
	int a[300]={0},c[10];
	float b[300]={0.0};
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		s+=a[i];
	}
	p=(float)s/n;
	q=0;w=0;

	for(i=0;i<n;i++){
		b[i]=a[i]-p;
		if(b[i]<0)
			b[i]=-b[i];
	}
	for(i=0;i<n;i++){
		if(b[i]>q)
			q=b[i];
	}
	for(i=0;i<n;i++){
		if(b[i]==q){
			c[w]=i;
			w++;
		}
	}
	for(i=0;i<w-1;i++)
		printf("%d,",a[c[i]]);
	printf("%d",a[c[w-1]]);
	return 0;
}
void main()
{
int a[300]={0},n,i,min,max;
float sum=0,ave,mid,mad;
scanf("%d",&n);
for(i=0;i<n;i++){scanf("%d",&a[i]);sum=sum+(float)a[i];}
ave=sum/n;
min=a[0];max=a[0];
for(i=0;i<n;i++){if(a[i]<min)min=a[i];if(a[i]>max)max=a[i];}
mid=ave-min;mad=max-ave;
if(mid>mad)printf("%d\n",min);
else if(mid<mad)printf("%d\n",max);
else printf("%d,%d\n",min,max);
}
int main()
{
    int n,i,j,temp,inpnum[300],max;
    float sum=0,ave,distance[300],tmpf;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++)       //???? 
    {
       scanf("%d",&inpnum[i]);
       sum+=inpnum[i];
    }
    ave=sum/n;//????? 
    
    for(i=0;i<n;i++)//???? 
    {
        if(inpnum[i]>ave)
        distance[i]=inpnum[i]-ave;
        else
        distance[i]=ave-inpnum[i];
    }
   /* printf("the distances are:");
    for(i=0;i<n;i++)
    printf(" %f ",distance[i]);
    printf("\n");*/
    
    for(i=0;i<n-1;i++)//?????????? 
    {
                    for(j=0;j<n-1;j++)
                    {
                        if(distance[j]<distance[j+1])
                        {
                            tmpf=distance[j];
                            distance[j]=distance[j+1];
                            distance[j+1]=tmpf;
                            
                            temp=inpnum[j];
                            inpnum[j]=inpnum[j+1];
                            inpnum[j+1]=temp;
                        }
                        else if(distance[j]==distance[j+1] && inpnum[j]>inpnum[j+1])
                        {
                            tmpf=distance[j];
                            distance[j]=distance[j+1];
                            distance[j+1]=tmpf;
                            
                            temp=inpnum[j];
                            inpnum[j]=inpnum[j+1];
                            inpnum[j+1]=temp;
                        }
                    }
                    
    }
   /* printf("\nafter the change, the diatances are:");
        for(i=0;i<n;i++)
    printf("%f ",distance[i]);
    printf("\n");*/
    
    max=distance[0];//max????? 
    printf("%d",inpnum[0]);//?????????? 
    
    for(i=1;i<n;i++)//????????????? 
    {
        if(distance[i]==max)
            printf(",%d",inpnum[i]);
        else
            break;
    }

    return 0;
}
int main()
{
	int i,j=0,n,a[300]={0},t,num=0,re[300];
	double ave=0,max=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		ave+=a[i];
	}
	ave/=n;
	for(i=0;i<n-1;i++)
		for(j=0;j<n-i-1;j++)
			if(a[j]>a[j+1])
			{
				t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;
			}
	for(i=0;i<n;i++)
		if(max<fabs((double)a[i]-ave))
			max=fabs((double)a[i]-ave);
	for(i=0;i<n;i++)
		if(fabs(max-fabs((double)a[i]-ave))<1E-5)
		{
			re[num]=a[i];
			num++;
		}
	if(num==1)
		cout<<re[0]<<endl;
	else
	{
		cout<<re[0];
		for(i=1;i<num;i++)
			cout<<","<<re[i];
		cout<<endl;
	}
	return 0;
}
int main()
{
	int a[ 100 ], n, i, j = 0, k = 0, t;
	float aver = 0;
	cin >> n;
	for ( i = 1 ; i <= n ; i ++ )
	{
		cin >> a [ i ];
		aver += a [ i ];
	}
	aver /= n;
	for ( i = n - 1 ; i >= 1 ; i -- )
		for ( j = 1 ; j <= i ; j ++ )
		{
			if ( a [ j ] < a [ j + 1 ] )
			{
				t = a [ j ];
				a [ j ] = a [ j + 1 ];
				a [ j + 1 ] = t;
			}
		}
	if ( fabs ( a [ 1 ] - aver ) > fabs ( a [ n ] - aver ) )
		cout << a [ 1 ] ;
	else
	{
		if ( fabs ( a [ 1 ] - aver ) == fabs ( a [ n ] - aver ) )
			cout << a [ n ] << "," << a [ 1 ];
		else cout << a [ n ];
	}
	return 0;
}
int main()
{
	int n,i,j,max;
	float average,sum=0,distance,maxdistance,temp,sign;
	unsigned int num[300];
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%d",&num[i]);
		sum=sum+num[i];
	}
	average=sum/n;
	for(i=1;i<n;i++)
	{
		for(j=n-1;j>=i;j--)
		{
			if(num[j]<num[j-1])
			{
				temp=num[j];
				num[j]=num[j-1];
				num[j-1]=temp;
			}
		}
	}
	maxdistance=0;
	for(i=0;i<n;i++)
	{
		distance=(num[i]-average>0)?(num[i]-average):(average-num[i]);
		if(distance>maxdistance)
			maxdistance=distance;
	}
	for(i=0;i<n;i++)
	{
		distance=(num[i]-average>0)?(num[i]-average):(average-num[i]);
		if(distance==maxdistance)
		{
			printf("%d",num[i]);
			break;
		}
	}
	for(i++;i<n;i++)
	{
		distance=(num[i]-average>0)?(num[i]-average):(average-num[i]);
		if(distance==maxdistance)
		{
			printf(",%d",num[i]);
			break;
		}
	}
	printf("\n");

	return 0;
}
void main()
{
	int n,i,j,q;
	float sum,ave,p1,p2,k1,k2;
	float a[300];
	scanf("%d",&n);
	for(i=0;i<=n-1;i++)
		scanf("%f",&a[i]);
	sum=0;
	for(i=0;i<=n-1;i++)
		sum=sum+a[i];
	ave=sum/n;

	q=0;
	for(i=0;i<=n-1;i++)
	{
		for(j=0;j<=n-1;j++)		
			if(a[j]<a[i])break;	
		if(j==n)
		{
			k1=ave-a[i];
			p1=a[i];q=1;
		}
		if(q==1)break;
	}
	
	q=0;
	for(i=0;i<=n-1;i++)
	{
		for(j=0;j<=n-1;j++)		
			if(a[j]>a[i])break;	
		if(j==n)
		{
			k2=a[i]-ave;
			p2=a[i];q=1;
		}
		if(q==1)break;
	}
	
	if(k1>k2)printf("%.0f",p1);
	else if(k1<k2)printf("%.0f",p2);
	else printf("%.0f,%.0f",p1,p2);
	

}
void main()
{
 unsigned int a[301],i,j,k,n,t;  
                  float av,cha[301],temp,sum=0;  
scanf("%d",&n);
	for(i=0;i<n;i++)
           {
              scanf("%d",&a[i]);
              sum=sum+a[i];
	} 
   	av=sum/n;   
	for(j=0;j<n;j++)  
		cha[j]=fabs(a[j]-av); 
         for(j=0;j<n;j++)
            for(k=0;k<n-j-1;k++)
              if(cha[k+1]>cha[k])
                    {temp=cha[k];t=a[k];
                    cha[k]=cha[k+1];a[k]=a[k+1];
                    cha[k+1]=temp;a[k+1]=t;}
 
      if(cha[0]!=cha[1])
           printf("%d",a[0]);
      else
        {if(a[0]>a[1])
           printf("%d,%d",a[1],a[0]);
        else
			printf("%d,%d",a[0],a[1]);}
}
//******************************************
//*???.cpp                    **
//*??: ??     1100012808              **
//*???2011.12.                       **
//******************************************
int main()  //???
{        //?????
	int n, t[100000] = {0}, i, flag = 0;
	double x, max = 0.0, sum = 0.0;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> t[i];
		sum += t[i];
	}
	x = sum / n;
	for (i = 0; i < n; i++)
		if (fabs(x - t[i]) > max)
			max = fabs(x - t[i]);
	for (i = 0; i < n; i++)
		if (fabs((x - t[i]) - max ) < 1e-5)
		{
			cout << t[i] ;
			flag = 1;
			break;
		}
	for (i = 0; i < n; i++)
		if (fabs(t[i] - x - max) < 1e-5)
		{
			if (flag)
				cout << "," ;
			cout << t[i] << endl;
			break;
		}
	return 0;
} //?????
int main()
{
	int i,n,m,j=0,c=0;
	unsigned int a[300],b[300];
	double av,cha,sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum=a[i]+sum;
	}
	av=sum/n;

	cha=fabs(av-a[0]);

	for(i=0,m=0;i<n;i++){
		if(cha<fabs(a[i]-av)){
			cha=fabs(a[i]-av);
			b[m]=a[i];
            j=1;
		}
	}
    if(j!=1){
		b[0]=a[0];
	}
	for(i=b[0]+1,m=1;i<n;i++){
		if(cha==fabs(a[i]-av)){
			b[m]=a[i];
			m++;
            c++;
		}
	}
	printf("%d",b[0]);
	for(i=1;i<=c;i++){
	printf(",%d",b[i]);

	}
	return 0;
}
int main()
{
	int a[302],i,count = 0;
	double y,n,num = 0,max = 0;
	cin >> n;
	for(i = 1; i <= n; i++)
	{
		cin >> a[i];
		num = num + a[i];
	}
	y = num / n;
	for(i = 1; i <= n; i++)
	{
		if(fabs(a[i] - y) > max)
			max = fabs(a[i] - y);
	}
	for(i = 1; i <= n; i++)
	{
		if(fabs(y - a[i] - max) < 0.0001)
		{
			count++;
			cout << a[i];
		}
		if(fabs(a[i] - y - max) < 0.0001)
		{
			if(count == 1)
				cout << "," << a[i] << endl;
			else
				cout << a[i] << endl;
		}
	}
	return 0;
}
void main()
{
	int num,*p,i,sum=0,s;
	float mean,*q,a,t;
	int j,k;
	scanf("%d",&num);
	p=(int*)malloc(sizeof(int)*num);
    q=(float*)malloc(sizeof(float)*num);
	for(i=0;i<num;i++)
	   scanf("%d",p+i);
	for(i=0;i<num;i++)
		sum=sum+p[i];
	    mean=((float)sum)/num;
	
	for(i=0;i<num;i++)
	{
		a=mean-p[i];
		q[i]=(a>=0)?a:(-a);
	}
        
    for(i=0;i<num;i++)
	{
		k=i;
		for(j=i+1;j<num;j++)
		{            
			if(q[j]>=q[k])
				k=j;
		}
		   if(k!=i)
			{
				t=q[k];
				q[k]=q[i];
				q[i]=t;
				s=p[k];
				p[k]=p[i];
				p[i]=s;
			}
	}
             	 
	if (q[0]!=q[1])
		printf("%d",p[0]);
	else
	{
		if(p[0]>=p[1])
			printf("%d,%d\n",p[1],p[0]);
		else
			if(p[0]<p[1])
			printf("%d,%d\n",p[0],p[1]);
	}
	free(p);
	free(q);
}
int n,i,a[400],j=0,m;
void main()
{
	float s=0,d=0,b[400],x;
	int c[400]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{	
		scanf("%d",&a[i]);
		s=s+a[i];
	}
	s=s/n;	
	for(i=0;i<n;i++)
	{
		if(a[i]>=s)	b[i]=a[i]-s;
		else	b[i]=s-a[i];
	}
	for(i=0;i<n;i++)
		if(b[i]>d)	d=b[i];
	for(i=0;i<n;i++)
	{	
		if(b[i]>d)	x=b[i]-d;
		else x=d-b[i];
		if(x<1e-6)	
		{
			if(a[i]<c[j])	
			{
				c[j+1]=c[j];
				c[j++]=a[i];
			}
			else	c[j++]=a[i];
		}
	}
	printf("%d",c[0]);
	for(i=1;i<j;i++)
		printf(",%d",c[i]);

}
int main()
{
	int n,i,j,num1,num2;
	double sum=0;
	unsigned a[300],temp;
	cin>>n;
	for(i=0;i<=n-1;i++)
		cin>>a[i];
	for(i=0;i<n;i++)
		sum=sum+a[i];
	sum=sum/n;
	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;
			}
	num1=0;
	i=0;
	while(a[i]==a[0])
	{
		num1++;
		i++;
	}
	num2=0;
	i=n-1;
	while(a[i]==a[n-1])
	{
		num2++;
		i--;
	}
	if(2*sum-a[0]-a[n-1]<0.000001&&a[0]+a[n-1]-2*sum<0.000001)
	{
		for(i=0;i<num1;i++)
			cout<<a[0]<<",";
		for(i=0;i<num2-1;i++)
			cout<<a[n-1]<<",";
		cout<<a[n-1];
	}
	else if(2*sum-a[0]-a[n-1]>=0.000001)
	{
		for(i=0;i<num1-1;i++)
			cout<<a[0]<<",";
	cout<<a[0];
	}
	else
	{
		for(i=0;i<num2-1;i++)
		
			cout<<a[n-1]<<",";
			cout<<a[n-1];
	}
	return 0;
	
}
int main()
{
    int str[301], n, i, j, temp, flag = 0; 
    double count = 0, max_num;
    cin >> n;
    for (i = 1; i <= n; i++)
        cin >> str[i];
    for (i = n; i >= 2; i--)
        for (j = 2; j <= i; j++)
            if (str[j] < str[j - 1])
            {
                temp = str[j - 1];
                str[j - 1] = str[j];
                str[j] = temp;
            }
    for (i = 1; i <= n; i++)
        count += str[i];
    max_num = max(str[n] - count / n, count / n - str[1]);
    for (i = 1; i <= n; i++)
        if (fabs(str[i] - count / n) > max_num || fabs(fabs(str[i] - count / n) - max_num) <= 1e-5)
        {
            if (flag == 0)
            {
               cout << str[i];
               flag = 1;
            }
            else
                cout << "," << str[i];
        }
    //while (1);
    return 0;
}
void main()
{
	int i,j=0,N,a[301]={0},b[100]={0},p,q,temp;
	int sum=0,max;
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}

	if(sum<a[0]*N)max=a[0]*N-sum;
	else max=sum-a[0]*N;
	for(i=1;i<N;i++)
		if(sum-a[i]*N>max)max=sum-a[i]*N;
		else if(a[i]*N-sum>max)max=a[i]*N-sum;
	for(i=0;i<N;i++)
		if(sum-a[i]*N==max||a[i]*N-sum==max)b[j++]=a[i];
	for(p=0;p<j-1;p++)
		for(q=p+1;q<j;q++)if(b[q]<b[p]){temp=b[p];b[p]=b[q];b[q]=temp;}
	for(i=0;i<j-1;i++)
		printf("%d,",b[i]);
	printf("%d\n",b[i]);

}
int main()
{
	int n,a[1000],i,sum=0,j,temp;
	char t=',';
	float m,b[1000],d,q;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(i=0;i<n;i++)
	{
		sum=sum+a[i];
	}
	m=sum/(n*1.0);
	for(i=0;i<n;i++)
	{
                q=a[i]-m;
		b[i]=abs(q);
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<(n-i);j++)
		{
			if(b[j]<b[j+1])
			{
			d=b[j];
			b[j]=b[j+1];
			b[j+1]=d;
			temp=a[j];
			a[j]=a[j+1];
			a[j+1]=temp;
			}
		}
	}
	if(b[0]!=b[1])
		cout<<a[0];
	else
	{
		cout<<a[0];
		for(i=1;i<n;i++)
		{
			if(b[i]==b[0])
			{
				cout<<t<<a[i];
			}
			else
				break;
		}
	}
	return 0;
}
int main()
{
	int n,t=0;
	int a[300],x[300];
	double p,m,b[300],s=0;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		s+=a[i];
	p=s/n;
	for(int i=0;i<n;i++)
		b[i]=fabs(a[i]-p);
	m=b[0];
	for(int i=0;i<n;i++)
		if(b[i]>m)
			m=b[i];
	for(int i=0;i<n;i++)
		if(b[i]==m)
			x[t++]=a[i];
	for(int i=0;i<t-1;i++)
		cout<<x[i]<<",";
	cout<<x[t-1]<<endl;
}
int main()
{
   int i,j;
   int n,m;
   double sum=0,av=0,b[1000],temp1;
   cin>>n;
   int a[1000]={0},temp2;
   for(i=0;i<=n-1;i++)
	   cin>>a[i];
   for(i=0;i<=n-1;i++)
	   sum=sum+a[i];
   av=sum/n;
   for(i=0;i<=n-1;i++)
	   b[i]=abs(a[i]-av);
   for(i=0;i<=n-2;i++)
	   for(j=0;j<=n-2-i;j++)
	      if(b[j]<b[j+1])
	      {
	    	  temp1=b[j];
	    	  b[j]=b[j+1];
	    	  b[j+1]=temp1;
	    	  temp2=a[j];
	    	  a[j]=a[j+1];
	    	  a[j+1]=temp2;
	      }
	  for(i=0;i<=n-1;i++)
	  if(b[0]!=b[i])
	  {
		  m=i;
		  break;

	  }
	  cout<<a[0];
	  for(i=1;i<=m-1;i++)
		  cout<<","<<a[i];
	  return 0;


}
void main()
{
	int n,i,j,k[100],sum=0,t,q;
	float a,p[100],t1;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&k[i]);
		sum+=k[i];
	}
	a=(float)sum/(float)n;
	for(j=1;j<n;j++)
	{
		for(i=0;i<n-j;i++)
		{
			if(k[i]>k[i+1])
			{
				t=k[i];
				k[i]=k[i+1];
				k[i+1]=t;
			}
		}
	}
	for(i=0;i<n;i++)
	{
		p[i]=a-k[i];
		if(p[i]<0)p[i]=-p[i];
	}
	for(i=0;i<n;i++)
	{
		q=0;
		if(p[i]>p[q])
		{
			q=i;
		}
		
	}
	printf("%d",k[q]);
	t1=p[q];
	p[q]=0;
	for(i=0;i<n;i++)
	{
		if(fabs(p[i]-t1)<=0.0000001)printf(",%d",k[i]);
	}


}
void main()
{
	int i,a[400];
	int n;
	int b[400];
	scanf("%d",&n);
	int sum=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++)
	{
		sum=sum+a[i];
	}
	for(i=0;i<n;i++)
	{
		if(n*a[i]>=sum)
			b[i]=n*a[i]-sum;
		else b[i]=sum-n*a[i];
	}
	int max=b[0];
	for(i=1;i<n;i++)
	{
		if(b[i]>max)
		{
			max=b[i];
		}
	}
	int flag=0;
	for(i=0;i<n;i++)
	{
		if(b[i]==max&&flag==1)
			printf(",%d",a[i]);
		if(b[i]==max&&flag==0)
		{
			printf("%d",a[i]);
			flag=1;
		}
	}
}
void main()
{
	int n,i,j=0;
	float a[100],total=0,temp1,temp2,temp,aa[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%f",&a[i]);
		total=total+a[i];
	}
	total=total/n;
	if(a[0]>=total)
		temp2=a[0]-total;
	else 
		temp2=total-a[0];
	for(i=1;i<n;i++)
	{
		if(a[i]>=total)
			temp1=a[i]-total;
	    else 
		    temp1=total-a[i];
		if(temp1>=temp2)
			temp2=temp1;
	}
	for(i=0;i<n;i++)
	{
		if(a[i]>=total)
			temp1=a[i]-total;
	    else if(a[i]<total)
		    temp1=total-a[i];
		if(temp1!=temp2)
		{
			a[i]=0;
		}
		else if(temp1==temp2)
		{
			aa[j]=a[i];
			j++;
		}
	}
	n=j-1;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
			if(aa[i]>aa[j])
			{
				temp=aa[j];
				aa[j]=aa[i];
				aa[i]=temp;
			}
	}
	printf("%.0f",aa[0]);
	for(i=1;i<=n;i++)
		printf(",%.0f",aa[i]);
}
int main()
{
	int n,i,j,r,sum=0,a[300],k;
	double t[300],p,b;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	for(j=n-1;j>0;j--)
	{
		for(r=0;r<j;r++)
			if(a[r]>a[r+1])
			{
				k=a[r];
				a[r]=a[r+1];
				a[r+1]=k;
			}
	}
	p=(double)sum/n;
	for(i=0;i<n;i++)
	{
		if((double)a[i]-p<0)
		{
			t[i]=p-(double)a[i];
		}
		else{t[i]=(double)a[i]-p;}
        if(t[i]>b)
		{
			b=t[i];
		}
	}
	for(i=0;i<n;i++)
	{
		if(t[i]==b)
		{
			printf("%d",a[i]);
			j=i;
            if(j<n-1)
			{
		       for(r=j+1;r<n;r++)
			   {
                   if(t[r]==b)
				   {
			          printf(",%d",a[r]);
			
				   }
			   }
			}
			break;
		}
		
		
	}
	
	
	
	return 0;

}
void main()
{
	int n,a[100],c[100],i,j=0;
	float ave=0,b[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){scanf("%d",&a[i]);ave=ave+a[i];}
	ave=ave/n;
	for(i=0;i<n;i++)b[i]=fabs(a[i]-ave);ave=b[0];
	for(i=0;i<n;i++)if(b[i]>ave)ave=b[i];
	for(i=0;i<n;i++)if(b[i]==ave)c[j++]=a[i];
	for(i=0;i<j-1;i++)
		for(n=i+1;n<j;n++)if(c[n]<c[i]){ave=c[n];c[n]=c[i];c[i]=ave;}
		for(i=0;i<j;i++){if(i==0)printf("%d",c[i]);else printf(",%d",c[i]);}
}
int main()
{
	int a[400];
	double sum=0;//???????????????
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
   sort(a, a + n);//??????????
 double average = sum / n;//????
   if (a[0] == a[n - 1])cout << a[0] << endl;
   else if (a[n-1] - average>average - a[0])cout << a[n-1]<<endl;
   else if (a[n-1] - average == average - a[0])cout << a[0] << ',' << a[n-1]<<endl;
   else cout << a[0] << endl;
   return 0;
}
main()
{
	int s1[300],i,n,j=0,a=0;
	float b,s2[300],c;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&s1[i]);
	for(i=0;i<n;i++)
		a+=s1[i];
	b=(float)a/n;
	for(i=0;i<n;i++)
	{
		s2[i]=s1[i]-b;
		if(s2[i]<0)
			s2[i]=0-s2[i];
	}
	for(i=1,c=s2[0];i<n;i++)
	{
		if(s2[i]>c)
		{
			c=s2[i];
			j=i;
		}
	}
	printf("%d",s1[j]);
	for(i=0;i<n;i++)
	{
		if(s2[j]==s2[i]&&i!=j)
			printf(",%d",s1[i]);
	}
}
void main()
{
	float a[300],c[300],pingjun,s=0,t,max=0,m,x;
	int n,i,j,jishuqi=0,k=0;
	scanf("%d",&n);
	for(i=0;i<=n-1;i++)
	{
		scanf("%f",&a[i]);
		s=s+a[i];
	}
	pingjun=s/n;
	for(j=0;j<=n-1;j++)
	{
		if(fabs(a[j]-pingjun)>max)
		{
			max=fabs(a[j]-pingjun);
		}
	}
	m=pingjun-max;
    x=pingjun+max;
	for(j=0;j<=n-1;j++)
	{
		if(a[j]<=m||a[j]>=x)
		{
			
			c[jishuqi]=a[j];
			jishuqi=jishuqi+1;
		}
	}
	if(jishuqi==1)
	{

		printf("%d",(int)(c[jishuqi-1]));
	}
	if(jishuqi>=2)
	{
		for(i=0;i<=jishuqi-2;i++)
			for(j=0;j<=jishuqi-2-i;j++)
			{
				if(c[j]>c[j+1])
				{
					t=c[j];
					c[j]=c[j+1];
					c[j+1]=t;
				}
			}
		printf("%d",(int)(c[0]));
		for(i=1;i<=jishuqi-1;i++)
		{
			printf(",%d",(int)(c[i]));
		}
	}
}
int main()
{
    int n,i,j,temp;
    cin>>n;
    double a[n];
    double dis[n],average,sum,temp0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    average=sum/n;
    for(i=0;i<n;i++)
    {
        dis[i]=abs(a[i]-average);
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<n-i-1;j++)
        {
            if(dis[j]>dis[j+1])
            {
                temp0=dis[j];
                dis[j]=dis[j+1];
                dis[j+1]=temp0;
                temp=a[j];
                a[j]=a[j+1];
                a[j+1]=temp;
            }
        }
    }
    for(i=0;i<n;i++)
    {
        if(dis[i]==dis[n-1])
        {
            cout<<a[i];
            i++;
            break;
        }
    }
    if(i<=n-1)
    {
        for(j=i;j<n;j++)
        {
            cout<<','<<a[j];
        }
    }
    return 0;
}
void main()
{
 double n;
 int i,j;
 double sum=0.0;
 int flag=1;
 double average=0.0;
 int a[300]={0},c[300]={-1},d[300]={0};//a[]???????d[]????????????a[k]
 double b[300]={0.0};//b[]??????
 scanf("%lf",&n);

 for(i=0;i<n;i++)
 {
	 c[i]=i;//c[]??????
	 scanf("%d",a+i);
	 sum=sum+*(a+i);
 }
 average=sum/n;
 for(j=0;j<n;j++)
	 b[j]=fabs(a[j]-average);
 for(i=0;i<n;i++)
	 for(j=i+1;j<n;j++)
	 {
		 if(b[i]<b[j])
		 {
		  int t;
		  double p;
		  t=c[i];
		  c[i]=c[j];
		  c[j]=t;
		  p=b[i];
          b[i]=b[j];
		  b[j]=p;
		 }
	 }
 for(i=0;i<n;i++)
 {
  if(b[i]==b[i+1])
	  flag=flag+1;
  else
	  break;//??break???????????????i=n-1??????flag??????
 }
 if(flag==1)
	 printf("%d",a[c[0]]);
 else
 {
 
	 {
 
		 for(i=0;i<flag;i++)
	 
			 d[i]=a[c[i]];
 
	 }
 for(i=0;i<flag;i++)
	 for(j=i;j<flag;j++)
	 {
	  if(d[i]>d[j])
	  {
	   int t;
	   t=d[i];
	   d[i]=d[j];
	   d[j]=t;
	  }
	 }
 for(i=0;i<flag-1;i++)
     printf("%d,",d[i]);
 if(i==flag-1)
	 printf("%d",d[i]);
 }
}
int main(){
	int n,a[305]={0},sum=0,b[305]={0},max=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum=sum+a[i];
		a[i]=a[i]*n;
		}
			for(int i=0;i<n-1;i++){
				for(int j=0;j<n-1-i;j++){
					if(a[j]>a[j+1]){
						int temp=a[j];
						a[j]=a[j+1];
						a[j+1]=temp;
						}
					}
				}
				for(int i=0;i<n;i++){
			        b[i]=abs(a[i]-sum);
			        if(b[i]>max)max=b[i];
			        }
			        int check=0;
			        for(int i=0;i<n;i++){
						if(b[i]==max){
							if(check==0)
							cout<<a[i]/n;
							else cout<<","<<a[i]/n;
							check=1;
							}
						}
						return 0;
	}