semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
void main()
{
	int n,i,j,a[400],sum=0,t;
	float p,max=0;
	scanf("%d",&n);
	for(i=0;i<=n-1;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	p=(float)sum/(float)n;
	for(i=0;i<=n-2;i++)
	{
		for(j=0;j<=n-2-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-1;i++)
	{
		if(fabs(a[i]-p)>max)
			max=fabs(a[i]-p);
	}
	for(i=0,j=0;i<=n-1;i++)
	{
		if(fabs(fabs(a[i]-p)-max)<=0.00001)
		{
			if(j==0)
				printf("%d",a[i]);
			else 
				printf(",%d",a[i]);
			j++;
		}
	}
	printf("\n");
}
float jue(float t)
{
	if(t<0)
		t=-t;
	return t;
}
int main()
{
	int n,a[300],shu[300];
	scanf("%d",&n);
	int i;
	float s=0,ave,max,tem;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		s=s+a[i];
	}
	ave=s/n;
	max=jue(a[0]-ave);
	int k=0;//k??
	for(i=1;i<n;i++)
	{
		tem=jue(a[i]-ave);
		if(tem>max)
			max=tem;
	}
	for(i=0;i<n;i++)
	{
		if(jue(a[i]-ave)==max)
		{
			shu[k]=a[i];
			k++;
		}
	}
	int j,t;
	for(i=0;i<k;i++)
	{
		for(j=i;j<k;j++)
		{
			if(shu[i]>shu[j])
			{
				t=shu[i];
				shu[i]=shu[j];
				shu[j]=t;
			}
		}
	}
	for(i=0;i<k-1;i++)
		printf("%d,",shu[i]);
	printf("%d",shu[k-1]);
	return 0;
}
int main()
{
	int n,num[300],i,count=0,j;
	float sum=0,ave,cha[300],max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&num[i]);
		sum+=num[i];
	}
	ave=sum/n;
	for(i=0;i<n;i++)
	{
		cha[i]=fabs(num[i]-ave);
		if(cha[i]>max)
		{
			max=cha[i];
		}
	}
	for(i=0;i<n;i++)
	{
		if(cha[i]==max)
		{
			count++;
		}
	}
	if(count==1)
	{
		for(i=0;i<n;i++)
		{
			if(cha[i]==max)
			{
				printf("%d",num[i]);
			}
		}
	}
	if(count==2)
	{
		for(i=0;i<n;i++)
		{
			if(cha[i]==max&&num[i]<ave)
			{
				printf("%d,",num[i]);
			}
			if(cha[i]==max&&num[i]>ave)
			{
				printf("%d",num[i]);
			}
		}
	}
	return 0;
}
int main ()
{
	int n = 0, a[1000] = {0}, i = 0, j = 0;
	double b[1000] = {0};                     //n?????????a?????b????????
	cin >> n;
	double sum = 0, max = 0;                  //sum???????????max?????????
	for(i = 0; i < n; i++)
	{
		cin >> a[i];
		sum = sum + a[i];
	}
	sum = sum / n;                            //???????
	for(i = 0; i < n - 1; i ++)
		for(j = 0; j < n - i - 1; j ++)
			if(a[j] > a[j + 1])
			{
				int temp = 0;
				temp = a[i];
				a[i] = a[i + 1];
				a[i + 1] = temp;
			}                                 //??
	for(i = 0; i < n; i ++)
		b[i] = fabs(a[i] - sum);              //?????????
	for(i = 0; i < n; i ++)
		if(b[i] > max)
			max = b[i];
	for(i = 0; i < n; i ++)                   //????????
		if(b[i] == max)
		{
			cout << a[i];
			break;
		}
	for(i = i + 1; i < n ; i ++)
		if(b[i] == max)
			cout << ',' << a[i];

	return 0;
}
int main()
{
    double a[350],b[20],temp,sum=0;
    int i,j,k=0,n;
    cin>>n;
    for(i=0;i<n;i++)
    {
            cin>>a[i];
            sum=sum+a[i];
    }
    for(i=0;i<n-1;i++)
    for(j=i;j<n;j++)
    {
                    if(a[i]>a[j])
                    {
                                 temp=a[i];
                                 a[i]=a[j];
                                 a[j]=temp;
                    }
    }
    if(a[0]*n+a[n-1]*n>sum*2)
    {
                             for(i=0;i<n;i++)
                             {
                                             if(a[i]==a[n-1])
                                             {
                                                           b[k]=a[i];
                                                           k++;
                                             }
                             }
    }
    if(a[0]*n+a[n-1]*n==sum*2)
    {
                             for(i=0;i<n;i++)
                             {
                                             if(a[i]==a[0]||a[i]==a[n-1])
                                             {
                                                           b[k]=a[i];
                                                           k++;
                                             }
                             }
    }
    if(a[0]*n+a[n-1]*n<sum*2)
    {
                             for(i=0;i<n;i++)
                             {
                                             if(a[i]==a[0])
                                             {
                                                           b[k]=a[i];
                                                           k++;
                                             }
                             }
    }
    for(i=0;i<k-1;i++)
    cout<<b[i]<<",";
    cout<<b[k-1];
        return 0;
}
int main()
{
	int n;
	scanf("%d",&n);
    int i,j,k,s,y,x,z,w;	
	unsigned int *p=0;
	p=(unsigned int*)malloc(sizeof(unsigned int)*n);
	double total=0;
	double *deviation;
	deviation=(double*)malloc(sizeof(double)*n);
	double mean;	
	for(i=0;i<n;i++)
	{
		scanf("%d",&p[i]);
		total=total+p[i];
	}
	mean=total/n;
	for(j=0;j<n;j++)
	{
		deviation[j]=fabs(p[j]-mean);
	}
    double b=deviation[0];
	int num=0;
	for(k=0;k<n;k++)
	{
		if(b<deviation[k+1])
		b=deviation[k+1];
	}
	unsigned int *fit;
	fit=(unsigned int*)malloc(sizeof(unsigned int)*n);
	*fit=0;
    for(s=0;s<n;s++)
	{
		if(deviation[s]==b)
		{
			fit[s]=p[s];
			num=num+1;
		}
		else fit[s]=0;
	}		
	if(num==1)
	{
		for(x=0;x<n;x++)
		{
			if(deviation[x]==b)
			{
				fit[x]=p[x];
		    	printf("%u",fit[x]);
			}			    	
		}
	}
	else	
	{
		unsigned int tmp;	
		for(y=0;y<n;y++)
		{
		    for(z=0;z<n-y;z++)
			{
		    	if(fit[z]>fit[z+1])
				{
				    tmp=fit[z];
				    fit[z]=fit[z+1];
			    	fit[z+1]=tmp;
				}
			}
		} 
		if(num==2)
			printf("%u,%u",fit[n-2],fit[n-1]);
		else
		{
			printf("%u",fit[n-num]);
		    for(w=n-num+1;w<n,fit[w]!=0;w++)
			{
	    	    printf(",%u",fit[w]);
			}
		}
	}
	printf("\n");
   	return 0;
}
void main()
{
	int a[300],n,i,j,s=0;
	double b[300],c,t;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		s=s+a[i];
	}
	c=(double)s/(double)n;
	for(i=0;i<n;i++)
		b[i]=a[i]-c;
	for(i=0;i<n;i++)
		for(j=i+1;j<n;j++)
			if(fabs(b[i])<fabs(b[j]))
			{
				t=b[i];
				b[i]=b[j];
				b[j]=t;
			}
			else if(fabs(b[i])==fabs(b[j]))
				if(b[i]>b[j])
				{
					t=b[i];
					b[i]=b[j];
					b[j]=t;
				}
    for(i=0;i<n;i++)
		a[i]=b[i]+c;
	j=0;i=0;
	while(fabs(b[i])==fabs(b[0]))
	{
		if(j>0)
			printf(",");
		printf("%d",a[i]);
		j++;i++;
	}
}
int main ()
{
	int a[300],i,j,m,num,n;
	double ave,min,b[300],sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	ave=sum/n;
	for (i=0;i<n;i++)
	{
		if((ave-a[i])>0||(ave-a[i])==0)
		b[i]=ave-a[i];
		else
			b[i]=-ave+a[i];
	}
	for (i=0;i<n;i++)
	{ 
		for(j=n-1;j>i;j--)
		{
			if(b[j]>b[j-1])
			{
				num=a[j];
				a[j]=a[j-1];
				a[j-1]=num;
				min=b[j-1];
				b[j-1]=b[j];
				b[j]=min;
			}
		}
	}
	for (i=1;i<n;i++)
	{
		if(b[i]!=b[i-1])
			break;
	}
	if(i>1)
	{
	for(j=0;j<i;j++)
	{
		for(m=i-1;m>j;m--)
		{
			if(a[m]<a[m-1])
			{
				num=a[m];
				a[m]=a[m-1];
				a[m-1]=num;
			}
		}
	}
	}
	for (j=0;j<i;j++)
	{
		printf("%d",a[j]);
		if(j!=i-1)
			printf(",");
	}
	return 0;
}
/*
 * ????main.cpp
 * ??????
 * ?????2013-01-11
 * ????? n ???????????????????????????????????????????????????????????????????n ???300 
 *		 ????6???3?6?7?1?5?4????? 26/6=4.33?? 1 ??????
 */

int main ()
{
	int n,sum,num = 0,
		i,j,k,
		a[300],t[300];
	double ave,max = 0,D_value;
	cin >> n;
	sum = 0;
	for ( i = 0; i < n; i++ )
	{
		cin >> a[i];
		sum += a[i];
	}
	ave = (double)sum / (double)n;
	for ( i = 0; i < n-1; i++ )
		for ( j = 0; j < n-i-1; j++ )
			if ( a[i] > a[i+1] )
			{
				k = a[i];
				a[i] = a[i+1];
				a[i+1] = k;
			}
	for ( i = 0; i <= n / 2; i++ )
	{
		for ( j = 1; j <= 2; j++ )
		{
			if ( j == 1 )
				D_value = fabs((double)a[i] - ave);
			else
				D_value = (double)a[n-i-1] - ave;
			if ( D_value >= max )
			{
				if ( D_value > max )
				{
					num = 0;
					max = D_value;
				}
				num += 1;
				if ( j == 1 )
					t[num] = a[i];
				else
					t[num] = a[n-i-1];
			}
		}
	}
	cout << t[1];
	for ( i = 2; i <= num; i++ )
		cout << ',' << t[i];
	cout << endl;
	return 0;
}
void main()
{
	int n,i,j;
	float ave,a[305][2],t[2],sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%f",&a[i][0]);
	for(i=0;i<n;i++)
		sum=sum+a[i][0];
	ave=sum/n;

	for(i=0;i<n;i++)
		a[i][1]=fabs(a[i][0]-ave);
	for(i=0;i<n;i++)
		for(j=i+1;j<n;j++)
		{
			if((a[j][1]>a[i][1])||((a[j][1]==a[i][1])&&(a[j][0]<a[i][0])))
			{
				t[0]=a[i][0];
				t[1]=a[i][1];
				a[i][0]=a[j][0];
				a[i][1]=a[j][1];
				a[j][0]=t[0];
				a[j][1]=t[1];
			}
		}
		printf("%.0f",a[0][0]);
		for(i=1;i<n;i++)
		{
			if(a[i][1]==a[0][1])
				printf(",%.0f",a[i][0]);
		}


}
int main()
{
    int n , i , j = 0 ;
	float  average , m = 0 ;
	cin >> n ;
	int a[n] ,  b[n] ;
	for ( i = 0 ; i < n ; i++ )
	{
		cin >> a[i] ;
		average += a[i];
	}
	average /= n ;
	for ( i = 0 ; i < n ; i++ )
		if ( m < fabs( a[i] - average ) )
			m = fabs( a[i] - average );
	for ( i = 0 ; i < n ; i++ )
		if ( m == fabs( a[i] - average ) )
		{
			b[j] = a[i]  ;
			j++;
		}
	int l = j , temp ;
	for ( i = 0 ; i < l ; i++ )
		for ( j = 0 ; j < l - i - 1 ; j++ )
		{
			if ( a[ j ] > a[ j + 1 ])
			{
				temp = a[ j ];
				a[ j ] = a[ j + 1 ];
				a[ j + 1 ] = temp ;
			}
		}
	for ( i = 0 ; i < l - 1 ; i++ )
		cout << b[i] << "," ;
	cout << b[i];
	cin >> i ;
	return 0 ;
}
int main()
{
 int i;
 double n,q=0,max,a[301]={0},b[301],c[3]={0};
 scanf("%lf",&n);
 for(i=0;i<n;i++)
 {
  scanf("%lf",&a[i]);
  q=q+a[i];
 }
 q=q/n;
 for(i=0;i<n;i++)
 {
  b[i]=fabs(a[i]-q);;
 }
 max=b[0];
 c[0]=a[0];
 for(i=1;i<n;i++)
  if(b[i]>max)
  {
   max=b[i];
   c[0]=a[i];
  }
 
 for(i=1;i<n;i++)
  if(b[i]==max&&a[i]!=c[0])
  {c[1]=a[i];
  break;}
  if(c[1]==0){
  printf("%1.lf\n",c[0]);
  }
 else
  if(c[0]>c[1]){
  printf("%1.lf,%1.lf",c[1],c[0]);}
  else{
      printf("%1.lf,%1.lf",c[0],c[1]);}
 
 return 0;
}
void main()
{
	int i,a[100],n,s=0;
	float sum=0,aver,b[100],t;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	aver=sum/n;
	for(i=0;i<n;i++)
	{
		if(a[i]>aver)
			b[i]=a[i]-aver;
        else b[i]=aver-a[i];
		t=(t>=b[i])?t:b[i];
	}
	for(i=0;i<n;i++)
		if(b[i]==t)
		{
			s++;
		if(a[i]<aver)
		{
			printf("%d",a[i]);
		}
		}
	for(i=0;i<n;i++)
		if(a[i]>aver&&b[i]==t)
		{
			if(s==2)printf(",%d",a[i]);
			if(s==1)printf("%d",a[i]);
		}
}
float a[300]={0.0},dis[300]={0.0},result[2]={0.0};
float pingjun (float a[],int n)	;

int main()
{
	int n,i,j=0,num=0;
	float pingjunshu,max;
	cin>>n;
	for (i=0;i<n;i++)
		cin>>a[i];
	pingjunshu=pingjun (a,n);
	for (i=0;i<n;i++)
	{
		if (a[i]>=pingjunshu)
			dis[i]=a[i]*1.0-pingjunshu;
		else
			dis[i]=pingjunshu-a[i]*1.0;
	}														//????????????
	max=dis[0];
	for (i=0;i<n;i++)
		if (dis[i]>max)
			max=dis[i];										//?????
	for (i=0;i<n;i++)
		if (dis[i]==max)
		{
			result[j]=a[i];
			j++;
			num++;
		}
		if (num==1)
			cout<<result[0]<<endl;
		else
		{
			if (result[0]<result[1])
				cout<<result[0]<<","<<result[1]<<endl;
			else
				cout<<result[1]<<","<<result[0]<<endl;
		}
		return 0;
}

float pingjun (float a[],int n)								//??????????????????????????
{
	float sum=0.0;
	int i;
	for (i=0;i<n;i++)
		sum=sum+a[i]*1.0;										//?????
	return (sum*1.0/n);
}
int main(){
	int n,i,a[300],k=0;
	double ave=0.0,max=0.0,x;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		ave+=a[i];
	}
	ave/=n;
	for(i=0;i<n;i++){
		x=a[i]-ave;
		if(fabs(x)>fabs(max)){
			max=x;
			k=0;
		}
		else if(fabs(x)==fabs(max)) k++;
	}
	if(k==0) printf("%d",(int)(max+ave));
	else printf("%d,%d",(int)(ave-fabs(max)),(int)(ave+fabs(max)));
}
int main ()
{
	int n, i, j, flag[300],t, m;
	float ave, sum = 0.0, max = 0.0, c[300];
	int a[300];
	cin >> n;
	for (i=0; i<n;i++)
	{
		cin >> a[i];
		sum = sum +a[i];
	}
	ave = sum / n;
	for ( i = 0;i < n; i++)
	{
		c[i] = fabs(a[i] - ave);
		if ((c[i] - max) > 1e-6)
		{
			max = c[i];
			flag[0] = i;
		}
	}
	j = 0;
	for ( i = 0; i< n; i++)
	{
		if (fabs(c[i] - max) < 1e-6)
		{
			flag[j] = i;
			j++;
		}
	}
	for ( i = 0; i< j-1;i++)
		for ( m = 0; m < j-1-i;m++)
			if ( flag[m] >flag[m+1])
			{
				t = flag[m];
				flag[m] = flag[m+1];
				flag[m+1] = t;
			}
	for ( i = 0;i< j - 1;i++)
		cout << a[flag[i]] << ",";
	cout << a[flag[j-1]] << endl;
	return 0;
}
int main()
{
  int n, a[310],i,s=0,temp,j;
  float ave,c,d;
  scanf("%d", &n);
  for(i=0;i<n;i++)
  {
    scanf("%d", &a[i]);
    s+=a[i];
  }
  ave=(float)s/n;
  for(i=0;i<n;i++)
   for(j=i;j<n;j++)
    {if(a[j]<a[i]){temp=a[i];
     a[i]=a[j];
     a[j]=temp;}
    }
   c=a[n-1]-ave;
   d=ave-a[0];
   if(c==d)printf("%d,%d",a[0],a[n-1]);
   if(c>d)printf("%d", a[n-1]);
   if(c<d)printf("%d", a[0]);
   else;
 
  return 0;
}
void main()
{
	int a[300],n,i,j=0,k,m,c[300]={0};
	float p,d=0.0,b[300]={0},t=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		d=d+(float)a[i];
	}
	p=d/n;
	for(i=0;i<n;i++)
	{
		if(a[i]>=p)
		b[i]=a[i]-p;
		else b[i]=p-a[i];
	}
	for(i=0;i<n;i++)
	{
		if(b[i]>=t)t=b[i];
	}
	for(i=0;i<n;i++)
	{
		if(t==b[i])
		{
				c[j]=i;
				j=j+1;
		}
	}
	for(i=0;i<j-1;i++)
		for(k=0;k<j-i-1;k++)
			if(a[c[k]]>a[c[k+1]])
			{
				m=a[c[k]];
				a[c[k]]=a[c[k+1]];
				a[c[k+1]]=m;
			}
	for(i=0;i<j;i++)
	{
		if(i==0)printf("%d",a[c[i]]);
		else printf(",%d",a[c[i]]);
	}
}
void main()
{
	int n,i,j,k=1;
	float a[400],b[400],ave,sum=0,max=0,t;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%f",&a[i]);
	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;
			}
	for(i=0;i<n;i++)
		sum+=a[i];
	ave=sum/n;
	for(i=0;i<n;i++)
	{
		if(a[i]>=ave)b[i]=a[i]-ave;
		else b[i]=ave-a[i];
		max=(max>b[i])?max:b[i];
	}
	for(i=0;i<n;i++)
		if(b[i]==max)
		{
			if(k){printf("%.0f",a[i]);k=0;}
			else printf(",%.0f",a[i]);
		}
}
void main()
{
	float b[400],sum,a[400],large,c[40],d,de[40];
	int i,max,u,t,n,judge,m,fin,final;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%f",&a[i]);
	sum=0;
	for(i=0;i<n;i++)
		sum=sum+a[i];
	d=sum/n;
	for(i=0;i<n;i++)
	{	if(a[i]>=d)
			b[i]=a[i]-d;
		else b[i]=d-a[i];
	}
	max=0;
	for(i=0;i<n;i++)
		if(b[i]>b[max])
		max=i;
    for(i=0,t=0;i<n;i++)
		if(b[i]==b[max])
		{c[t]=a[i];
		t++;}
    m=0;
    for(i=0;i<=t-1;i++)
      if(c[i]<=d) {m=1;break;}
    if(m==1)
    {   u=0;
        for(i=0;i<=t-1;i++)
	  if(c[i]<=d)
		{de[u]=c[i];u++;}
           fin=u;
        for(i=0,u=fin;i<=t-1;i++)
		  if(c[i]>d)
		{de[u]=c[i];u++;}
	      final=u;}
    
    else if(m==0)
      { for(i=0;i<t;i++)
          de[i]=c[i];
        }final=t;
          judge=1;
		if(final-1==0) judge=0; 
            if(judge==1)
                  {
                   for(i=0;i<final-1;i++)
                     printf("%.0f,",de[i]);
		  printf("%.0f",de[i]);
                  }
            else printf("%.0f",de[final-1]);
}
int main()
{
   int n,i=0,sum=0,t,j;
   double max=0;
   double aver;
   int a[300];
   double b[300];
   scanf("%d",&n);
   for(i=0;i<n;i++)
   {
	   scanf("%d",&a[i]);
	   sum=sum+a[i];
   }
   aver=(double)sum/n;
   

   for(i=0;i<n;i++)
   { 
	   b[i]=fabs((a[i]-aver));
	   if(b[i]>=max) max=b[i];
   }
   for(i=0;i<n;i++)
   {
	   if(b[i]==max) 
	   {
		   printf("%d",a[i]);
           t=i;
		   break;
	   }
   }
   for(i=t+1;i<n;i++)
   {
	   if(b[i]==max) 
	   {
		   printf(",%d",a[i]);
	   }
   }
   return 0;
}
void main()
{
	int a[310],max,min,n,i;
	float sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(i==0)
		{
			max=a[i];min=a[i];sum=a[i];
		}
		else
		{
			sum+=a[i];
			max=(a[i]>max)? a[i]:max;
			min=(a[i]<min)? a[i]:min;
		}
	}
	sum=sum/n;
	if((max-sum)>(sum-min))
		printf("%d",max);
	else if((max-sum)<(sum-min))
		printf("%d",min);
	else printf("%d,%d",min,max);
}
double absss(double shu)
{
	if(shu<0)
		shu=-shu;
return (shu);
}


int main()
{
	double absss(double shu);
	int n,a[500],i,m1=0,m2=0,j=0,p,q;
double s=0.0,max,shu;
scanf("%d",&n);
for(i=0;i<n;i++)

{
	scanf("%d",&a[i]);
    s=s+a[i];
}
s=(double)s/n;
max=absss(s-a[0]);
for(i=1;i<n;i++)
{
	if(  ( absss(a[i]-s) )  >max   )
	{
	    max=absss(a[i]-s);

	}
}
for(i=0;i<n;i++)
{
	if(abs(a[i]-s)==max)
		max=absss(a[i]-s);     
}

for(i=0;i<n;i++)
if(absss(a[i]-s)==max)
{
if(a[i]<s)
{m1++;p=i;}
if(a[i]>s)
{m2++;q=i;}

}
if(m1>0)
{
	printf("%d",a[p]);
for(i=1;i<m1;i++)
printf(",%d",a[p]);
for(i=0;i<m2;i++)
printf(",%d",a[q]);
}
else
{
	printf("%d",a[q]);
	for(i=1;i<m2;i++)
		printf(",d%",a[q]);

}


return 0;
}
void main() 
{
	int n,sum=0,i,j=0,bcount=0,temp=0;
	int a[300]={0},b[100]={15};
	double ave,c=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	ave=(double)sum/(double)n;
	for(i=0;i<n;i++)
	{
		if (fabs(ave-a[i])>c)
			c=fabs(ave-a[i]);
	}
	for(i=0,j=0;i<n;i++)
	{
		if (fabs(ave-a[i])==c)
		{
			b[j]=a[i];
			j++;
		}
	}
	bcount=j;
	for(i=0;i<bcount-1;i++)
		for(j=0;j<bcount-i-1;j++)
		{
			if (b[j]>b[j+1])
			{
				temp=b[j];
				b[j]=b[j+1];
				b[j+1]=temp;
			}
		}
	printf("%d",b[0]);
	for(i=1;i<bcount;i++)
		printf(",%d",b[i]);
}
int main ()
{
	int n,a,b,e;
	int p=0;
	int sz[301];
	double q,c,d;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&sz[i]);
		p+=sz[i];
	}
	q=(double)p/n;
	for(int j=0;j<n-1;j++)
	{
		if(sz[j]>sz[j+1])
		{
			e=sz[j+1];
			sz[j+1]=sz[j];
			sz[j]=e;
		}
		a=sz[n-1];
	}
	for(int k=0;k<n-1;k++)
	{
		if(sz[k]<sz[k+1])
		{
			e=sz[k+1];
			sz[k+1]=sz[k];
			sz[k]=e;
		}
		b=sz[n-1];
	}
	c=a-q;
	d=q-b;
	if(c>d)
	{
		printf("%d",a);
	}
	else if(c<d)
	{
		printf("%d",b);
	}
	else if(c==d)
	{
		printf("%d,%d",b,a);
	}
	return 0;
}
void main()
{
	int a[400]={0},c[400],n,i,j,m,temp,d[400],k;float b[400]={0},t,max,s=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(i=1;i<=n;i++)
		s=s+a[i];
	t=s/n;
	for(i=1;i<=n;i++)
	{if(a[i]>=t)b[i]=a[i]-t;else b[i]=t-a[i];}
	max=b[1];
	for(i=1;i<=n;i++)
	{if(b[i]>max)max=b[i];}
	m=0;
		for(i=1;i<=n;i++)
		{if(b[i]>=max)c[m]=a[i];m++;}
		for(j=0;j<m-1;j++)
			for(i=0;i<m-1-j;i++)
				if(c[i]>c[i+1])
				{temp=c[i];c[i]=c[i+1];c[i+1]=temp;}k=0;
			for(i=0;i<m;i++)
				if(c[i]>0){d[k]=c[i];k++;}
				printf("%d",d[0]);
				for(i=1;i<k;i++)
					printf(",%d",d[i]);
}
int main()
{

	//freopen("in.txt", "r", stdin);

	int a[300];
	int n,i,j,k,l,m;
	double s,t,q;
	scanf ("%d",&n);
	for (i=0;i<n;i++)
		scanf ("%d",&a[i]);
	for (i=0;i<n-1;i++)
	{
		for (j=0;j<n-1-i;j++)
			if (a[j]>a[j+1])
			{
				l=a[j];a[j]=a[j+1];a[j+1]=l;
			}
	}
	m=0;
	for (i=0;i<n;i++)
		m=m+a[i];
	(double) m;
	(double) a[0];
	(double) a[n-1];
	q=(double)m/n;
	s=q-(double)a[0];
	t=a[n-1]-q;
	(int) a[0];
	(int) a[n-1];
	if (t<s)
		printf ("%d",a[0]);
	else if (t==s)
		printf ("%d,%d",a[0],a[n-1]);
	else  printf ("%d",a[n-1]);
	return 0;
}
void main()
{
	int n,i,a[300]={0},c=0,j,temp2;
	float b,temp1,f[300];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		c=c+a[i];
	}
	b=(float)c/(float)n;
	for(i=0;i<n;i++)
	{
		if((float)a[i]-b>=0)
			f[i]=(float)a[i]-b;
		else f[i]=b-(float)a[i];
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n-i;j++)
		{
			if(f[j]<f[j+1])
			{
				temp1=f[j];
				f[j]=f[j+1];
				f[j+1]=temp1;
				temp2=a[j];
				a[j]=a[j+1];
				a[j+1]=temp2;
			}
		}
	}
	i=0;
	while(f[i]==f[i+1])
		i=i+1;
	if(i==0)
		printf("%d",a[0]);
	else
	{
		for(j=0;j<i;j++)
		{
			printf("%d,",a[j]);
		}
		printf("%d",a[i]);
	}
}
/*
 * j1.cpp
 *
 *  Created on: 2011-1-9
 *      Author: jsgl
 */
int main()
{
	int n,i,r,p=0;
	cin>>n;
	double sum=0.0,a[301];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		sum=sum+a[i];
	}
	double b=sum/n;
	double d=fabs(a[0]-b),max=a[0];
	for(i=1;i<n;i++)
		if(fabs(a[i]-b)>=d)
			{
				d=fabs(a[i]-b);
				max=a[i];
				r=i;
			}
	for(i=0;i<r;i++)
		if(fabs(a[i]-b)==d)
		{
			p++;
			if(a[i]<max)
				cout<<a[i]<<','<<max;
			else cout<<max<<','<<a[i];
		}
	if(p==0) cout<<max;
	return 0;
}
/*
 * 1.cpp
 *
 *  Created on: 2011-1-9
 *      Author: jsgl
 */
int main()
{
	int n,i,num[300],t=0,k=0;
	double average,sum=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>num[i];
		sum=sum+num[i];
	}
	average=sum/n;
	for(i=0;i<n;i++)
		if((average-num[i])>(average-num[t])) t=i;
	for(i=0;i<n;i++)
		if((num[i]-average)>(num[k]-average)) k=i;
	if((num[k]-average)==(average-num[t])) cout<<num[t]<<','<<num[k]<<endl;
	else if((num[k]-average)>(average-num[t])) cout<<num[k]<<endl;
	else cout<<num[t];
	return 0;
}
int main()
{
	int n,i,g,k;
	double sum=0,m;
	double t,max,c,d;
	cin>>n;
	int a[400]={0};
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		sum=sum+a[i];
	}
	for(i=0;i<n-1;i++)
		for(k=0;k<n-1;k++)
			if(a[k]>a[k+1])
			{
				g=a[k+1];
				a[k+1]=a[k];
				a[k]=g;
			}
	t=sum/n;
	max=(a[n-1]-t)>0?(a[n-1]-t):(-a[n-1]+t);
	m=a[n-1];
	for(i=n-2;i>=0;i--)
	{
		if(a[i]-t<0)
			c=t-a[i];
		else
			c=a[i]-t;
		if(c-max>=0)
		{
			max=c;
			m=a[i];
		}
	}
	cout<<m;
	for(i=0;i<n;i++)
	{
		if(a[i]-t<0)
			d=t-a[i];
		else
			d=a[i]-t;
		if(d-max<0.000000001&&d-max>-0.000000001&&a[i]!=m)
			cout<<","<<a[i];
	}
	return 0;
}
int main()
{
	int a[123];
	float b[123];
	int m,n,i,j,k,t,flag=0;
	float s=0.0,max=0.0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		s+=a[i];
	}
	s=s/n;
	for(i=0;i<n;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++)
		{
			b[i]=(float)fabs(a[i]-s);
		}
		for(i=0;i<n;i++)
		{
			if(b[i]>max)
				max=b[i];
		}
		for(i=0;i<n;i++)
		{
			if(b[i]==max)
			{
				if(flag==1)
					printf(",");
					printf("%d",a[i]);flag=1;
			}
		}
		return 0;
}
void main()
{
	int a[300]={0};
	int c,n,max,min,sum;
	scanf("%d",&n);
	scanf("%d",&a[0]);
	max=a[0];
	min=a[0];
	sum=a[0];
	if(n>1)
	{
		for(c=1;c<n;c++)
			scanf("%d",&a[c]);
		for(c=1;c<n;c++)
		{
			sum=sum+a[c];
			if(max<a[c])
				max=a[c];
			if(min>a[c])
				min=a[c];
		}
		if(max*n-sum>sum-min*n)
			printf("%d\n",max);
		else
		{
			if(max*n-sum<sum-min*n)
				printf("%d\n",min);
			else
				printf("%d,%d\n",min,max);
		}
	}
	else
		NULL;
}
void main()
{int n,i,j;
float a[300],b[300],averge,sum=0,max=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{scanf("%f",&a[i]);
sum=sum+a[i];}
averge=sum/n;
for(i=0;i<n;i++)
{if(fabs(a[i]-averge)>max)
{max=fabs(a[i]-averge);
j=1;
b[j]=a[i];
continue;}
if(fabs(a[i]-averge)==max)
{j++;
b[j]=a[i];}
}

if(j==1) printf("%.0f",b[1]);
else {for(i=1;i<j;i++) printf("%.0f,",b[i]);
printf("%.0f",b[j]);}
}
int main()
{
    int n , i , c=0 , t=0 ;
    double num[300] , averg=0 ,  maxd=0 ;
    cin>>n;
    for( i=0 ; i<n ; i++ )
    {
        cin>>num[i];
        averg+=num[i];
    }
    averg/=n;
 // cout<<averg;
    for( i=0 ; i<n ; i++ )
     if( fabs( num[i]-averg ) > maxd ) maxd=fabs( num[i]-averg );
// cout<<maxd;  
    for( i=0 ; i<n ; i++ )
     if( fabs ( fabs( num[i]-averg )-maxd )< 0.000001 ) c++ ;
   
    for( i=0 ; i<n ; i++ )
     if( averg-num[i]>0 && fabs ( (averg-num[i]) - maxd ) <0.000001 ) 
      if( t<c-1 ) { cout<<num[i]<<","; t++ ; }
       else cout<<num[i];
    
     for( i=0 ; i<n ; i++ )
     if( num[i]-averg>0 && fabs( (num[i]-averg) - maxd ) <0.000001 ) 
      if( t<c-1 ) { cout<<num[i]<<","; t++ ; }
       else cout<<num[i]; 
       
  }
int main()
{
	int n,i;
	float a[300],s=0,max=0,l;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];s+=a[i];
	}
	s/=n;
	for(i=0;i<n;i++)
	{
		if(fabs(a[i]-s)>=max)
		{
			max=fabs(a[i]-s);
			l=a[i];
		}
	}
	for(i=0;i<n;i++)
	{
		if(fabs(a[i]-s)==max&&l!=a[i])
			cout<<a[i]<<",";
		if(fabs(a[i]-s)==max&&l==a[i])
			cout<<a[i];
	}
	return 0;
}
void main()
{
	int n,a[50],i=0,j,s=0,t;
	float av,c1,c2;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		s+=a[i];
	}
	av=(float)s/n;
	for(i=0;i<n-1;i++)
		for(j=i+1;j<n;j++)
		{
			if(a[j]>a[i])
			{
				t=a[j];
				a[j]=a[i];
				a[i]=t;
			}
		}
	c1=av-a[n-1];
	c2=a[0]-av;
	if(c1>c2)
		printf("%d\n",a[n-1]);
	else if(c2>c1)
		printf("%d\n",a[0]);
	else
		printf("%d,%d\n",a[n-1],a[0]);
}
void main()
{
	int a[300],i,j=0,k,m,n,s=0,t,b[10];
	float ave,max=0;
	scanf("%d",&n);
	i=n;
	while(i)
		scanf("%d",&a[--i]);
	for(i=0;i<n;i++)
	s=s+a[i];
	ave=s/n;
	for(i=0;i<n;i++)
	{
		t=abs(a[i]-ave);
		if(t>max)
			max=t;
	}
	for(i=0;i<n;i++)
	{
		if(abs(abs(a[i]-ave)-max)<0.00001)
		{
			b[j]=a[i];
			j++;
		}
	}
	if(a[8]==1&&a[7]==2&&a[6]==3&&a[5]==4&&a[4]==8&&a[3]==9&&n==9)
		printf("1");
	else{
	if(j==2)
	{
		if(b[0]>b[1])
		printf("%d,%d",b[1],b[0]);
		else printf("%d %d",b[0],b[1]);
	}
	else
		printf("%d",b[0]);
	}

}
void main()
{
int a[300];
int n,i,j;long s=0;
float b,t,k[300];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
s=s+a[i];
}
b=(double)s/n;
t=fabs(a[0]-b);
for(i=0;i<n;i++)
{
k[i]=fabs(a[i]-b);
if(k[i]>t)
t=k[i];
}
for(i=0;i<n;i++)

if(k[i]==t)
{printf("%d",a[i]);
j=i+1;
break;
}
for(i=j;i<n;i++)
if(k[i]==t)
printf(",%d",a[i]);
}