semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int i,j,tmp,n,sum=0,p=0;
	double average=0,b[300]={0},max=0;
	int a[300]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	for(i=1;i<n;i++)
		for(j=0;j<n-i;j++)
		{
		if(a[j]>a[j+1])
		{
			tmp=a[j+1];
			a[j+1]=a[j];
			a[j]=tmp;
		}
		}
	average=(sum*1.0)/(n*1.0);
	for(i=0;i<n;i++)
		b[i]=fabs(a[i]-average);
	
	for(i=0;i<n;i++)
		if(max<b[i]) max=b[i];
	for(i=0;i<n;i++)
	{	if(b[i]==max) {printf("%d",a[i]); p=i;break;}}
	for(i=p+1;i<n;i++)
		if(b[i]==max) printf(",%d",a[i]);

	return 0;
}
int main()
{
	int n, i, j, a[301], sum = 0, p;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> a[i];
		sum = sum + a[i];
	}
    for (j = 1; j < n; j++)
	{
		for (i = 1; i <= n -j; i++)
		{
			if (a[i] > a[i+1])
			{
				p = a[i];
				a[i] = a[i+1];
				a[i+1] = p;
			}
		}
	}
    int  g[301],num[301] = {0};
    double sum1, aver, b[301], q= 0;
	sum1 = sum;
	aver = sum1 /n;
    for (i = 1; i <= n; i++)
	{
		if (a[i] - aver < 0) b[i] = aver - a[i];
		else b[i] = a[i] -aver;
		if (b[i] > q)
		{
			q = b[i];
		}
	}
    for (i = 1; i <= n; i++)
	{
		if (b[i] == q)
		{
			num [i] = i;
		}
	}
	q = 1;
    for (i = 1; i <= n; i++)
	{
		if (num[i] == 0) continue;
		else
		{
			g[i] = q;
			q++;
		}
	}
    for (i = 1; i <= n; i++)
	{
		if (num[i] == 0) continue;
		else
		{
			if (g[i] == 1) cout <<a[i];
			else
			{
				cout << "," << a[i];
			}
		}
	}
	return 0;
}
int main()
{
	int n,i=0,j=0,k=0;
	float a[310];
	float sum=0,aver;
	float b[310],c[310],max,tem;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%f",&a[i]);
	}

	for(i=1;i<=n;i++)
	{
		sum=sum+a[i];
	}
	aver=sum/n;

	for(i=1;i<=n;i++)
	{
		b[i]=a[i]-aver;
		if(b[i]<0)
		{
			b[i]=-b[i];
		}
	}

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

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

	if(j==1)
	{
		printf("%.f",c[1]);
	}
	else
	{
		for(i=j;i>1;i--)
		{
			for(k=1;k<i;k++)
			{
				if(c[k]>c[k+1])
				{
					tem=c[k];
					c[k]=c[k+1];
					c[k+1]=tem;
				}
			}
		}

		printf("%.f",c[1]);
		for(i=2;i<=j;i++)
		{
			printf(",%.f",c[j]);
		}
	}



	return 0;
}
int main()
{
	int n,a[300],t;
	double sum=0,average;
	cin>>n;
	for (int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	average=sum/n;
	for (int j=0;j<n-1;j++)
	{
		for (int k=n-1;k>j;k--)
		{
			if (a[k]<a[k-1])
			{
				t=a[k];a[k]=a[k-1];a[k-1]=t;
			}
		}
	}
	if (  (average-a[0])>(a[n-1]-average) )
		cout<<a[0]<<endl;
	else if (  (average-a[0])<(a[n-1]-average) )
		cout<<a[n-1]<<endl;
	else if (  (average-a[0])==(a[n-1]-average) )
		cout<<a[0]<<","<<a[n-1]<<endl;
	return 0;
}
int main()
{
	int n,a[300];
	double b[300];
	cin >> n;
	int i,begin=0;
	double average,sum=0,max,counter=0;
	for(i=0;i<n;i++)
	{
		cin >> a[i];
		sum=sum+a[i];
	}
	average=sum/n;
	for(i=0;i<n;i++)
	{
		if( a[i] > average)
		{
			b[i] = a[i] - average;
		}
		if( a[i] < average )
		{
			b[i] = average - a[i];
		}
	}
	max= b[0];
	for(i=1;i<n;i++)
	{
		if( b[i] > max)
		{
			max = b[i];
			begin = i;
		}
	}
	for (i=0;i<n;i++)
	{
		if( fabs(b[i] - max) < 1e-5)
		{
			counter++;
		}
	}
	if(counter >= 2)
	{
		cout << a[begin];
		for( i= begin+1;i<n;i++)
		{
			if( fabs(b[i] - max) < 1e-5)
			{
				cout << "," << a[i];
			}
		}
	}
	else cout << a[begin] << endl;
	return 0;
}
int main()
{
	int n,i,flag;
	int a[300];
	double sum,ave,max;
	double b[300];
	scanf("%d",&n);
	sum=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	ave=sum/n;
	for(i=0;i<n;i++)
	{
		b[i]=((double)a[i]-ave);
		if(b[i]<0)
			b[i]=-b[i];

	 }
	max=b[0];
	for(i=1;i<n;i++)
	{
		if(b[i]>max)
		{
			max=b[i];
		}
	}
    flag=0;
	for(i=0;i<n;i++)
	{
		if(b[i]==max)
		{
			if(flag==0)
			{
				printf("%d",a[i]);
	            flag=1;
			}
			else
			{
				printf(",%d",a[i]);
			}
		}
	}
	return 0;
}
/* Note:Your choice is C IDE */
void main()
{
	int a[100],n,i,j,t,sum=0;
	float x,y,z;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&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++)
	{sum+=a[i];}
	
	x=(float)sum/n;
	y=a[n-1]-x;
	z=x-a[0];
	if(y>z) 
	{printf("%d",a[n-1]);
		for(i=1;i<n-1;i++)
		if(a[i]-x==y)
		printf(",%d",a[i]);
	}
	else
	{printf("%d",a[0]);
		for(i=1;i<=n-1;i++)
		if(a[i]-x==z||x-a[i]==z)
		printf(",%d",a[i]);
	}
}
int main()
{
	int n, i, s, k, j, p;
	int a[300];
	cin >> n;
	float ave, max;
	
	s=0;
	max = 0;
	k=0;
	for (i=0;i<n;i++)
	{
		cin >> a[i];
		s=s+a[i];
	}
	ave = s / 1.0 / n;


	for (i=0;i<n;i++)
		if (fabs(ave - a[i]) >= max)
			max = fabs(ave - a[i]);
	for (i=0;i<n;i++)
		if (max-fabs(ave - a[i])<0.001)
		{
			a[k]=a[i];
			k++;
		}
	if (k == 1)
		cout << a[0] << endl;
	else
	{
		for (i=0;i<k-1;i++)
			for (j=0;j<k-1-i;j++)
				if (a[j]>a[j+1])
				{
					p=a[j];
					a[j]= a[j+1];
					a[j+1]=p;
				}
		cout << a[0] ;
		for (i=1;i<k;i++)
			cout << "," << a[i];
		cout << endl;

	}

	return 0;

}
void main()
{
	double a[300],s=0,b[300];
	double n;
	scanf("%lf",&n);
	int i;
	for(i=0;i<n;i++)
	{
		scanf("%lf",&a[i]);
		s=s+a[i];
	}
	double mv=s/n;
	i=0;
    for(i=0;i<n;i++)
	{
		if(a[i]-mv>=0) b[i]=a[i]-mv;
		else b[i]=mv-a[i];
	}
    int j;
	double t,r;
	i=0;
	for(i=0;i<n;i++)
		for(j=0;j<n-i;j++)
		{
			if(b[j]<b[j+1])
			{
				t=b[j];
				b[j]=b[j+1];
				b[j+1]=t;
				r=a[j];
				a[j]=a[j+1];
				a[j+1]=r;
			}
		}
	i=1;
	printf("%d",(int)a[0]);
	while(b[i]==b[0])
	{
       printf(",%d",(int)a[i]);
	   i++;
	}
    
}
int main()
{
	int n,a[310],i,temp;
	double b[310],max=-100,ave,s=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		s=s+a[i];
	}
	ave=s/n;
	for(i=0;i<n;i++)
	{
		b[i]=fabs(ave-a[i]);
		if(b[i]>max)max=b[i];
	}
	for(i=0;i<n;i++)
		if(fabs(b[i]-max)<0.0001){
			printf("%d",a[i]);
			temp=i;
			break;
		}
	for(i=temp+1;i<n;i++)
		if(b[i]==max)
			printf(",%d",a[i]);
	return 0;
}
int main()
{
  int n,a[300]={0},j,i,sum=0,temp;
  float b,c[300]={0},min;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
        scanf("%d",&a[i]);
        sum+=a[i];
  }
  b=(float)sum/n;
  //printf("%f\n",b);??
  for(i=0;i<n;i++)
  {
        if(a[i]>b)
        c[i]=a[i]-b;
        else
        c[i]=b-a[i];
       // printf("%f\n",c[i]);
  }
  for(i=1;i<n;i++)
  {
        for(j=n-1;j>=i;j--)
        {
            if(c[j-1]>c[j])
            {
             min=c[j];
              c[j]=c[j-1];
              c[j-1]=min;
              temp=a[j];
              a[j]=a[j-1];
              a[j-1]=temp;
            }
        }
  }
  if(c[n-1]==c[n-2])
  { 
     
   
     if(a[n-2]>a[n-1])
     {
         temp=a[n-1];
         a[n-1]=a[n-2];
         a[n-2]=temp;
     }
   

     printf("%d,%d",a[n-2],a[n-1]);
   
    
  }
  else
  printf("%d",a[n-1]);
  return 0;
  
}
int a(int k)
{
    if(k>0)
    return k;
    return -k;
}
int main()
{
    int num[300];
    int n,i,flag=1;
    int sum=0,max=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
    scanf("%d",&num[i]);
    sum+=num[i];
    }
    for(i=1;i<=n;i++)
    {
                    if(max<a(num[i]*n-sum))
                    max=a(num[i]*n-sum);
    }
    for(i=1;i<=n;i++)
    {
                     if(max==sum-num[i]*n)
                     {
                                          if(flag==0)
                                          printf(",");
                                          flag=0;
                     printf("%d",num[i]);
                     }
    }
    for(i=1;i<=n;i++)
    {
                     if(max==-sum+num[i]*n)
                     {                    if(flag==0)
                                          printf(",");
                                          flag=0;
                     printf("%d",num[i]);
                     }
    }
    return 0;
}
int main()
{
  int n,i;
  double sum;
  int a[300];
  cin >>n;
  sum=0;
  for (i=0;i<n;i++)
  {
    cin >>a[i];
    sum+=a[i];
  }
  double junzhi=sum/n; 
  double b[300];
  double max=0;
  for (i=0;i<n;i++)
  {
    if (a[i]<junzhi)
      b[i]=junzhi-a[i];
    else
      b[i]=a[i]-junzhi;
    if (b[i]>max) max=b[i];
  }
  int c[300];
  int m=-1;
  for (i=0;i<n;i++)
    if (max==b[i])
    {
      m++;c[m]=a[i];
    }
  m++;int j;
  for (i=0;i<m;i++)
	  for (j=i+1;j<m;j++)
		  if (c[i]>c[j])
		  {
			  sum=c[i];c[i]=c[j];c[j]=sum;
		  }
  cout << c[0];
  for (i=1;i<m;i++)
	  cout <<',' <<c[i];
  return 0;
}
int main()
{
int n;
cin>>n;
float sum;
int a[300];
for(int i=0;i<=n-1;i++)
{

cin>>a[i];
sum=sum+a[i];
}
int k;
for(int i=0;i<n-1;i++)
{
for(int s=0;s<n-1-i;s++)
{
if(a[s]>a[s+1])
{
k=a[s];
a[s]=a[s+1];
a[s+1]=k;
}
}
}
float pingjun=sum/n;
float h=pingjun-a[0],t=a[n-1]-pingjun;
if(h==t)
{
cout<<a[0]<<","<<a[n-1]<<endl;
}
else if(h>t)
{
cout<<a[0];
}
else if(h<t)
{
cout<<a[n-1];
}
return 0;
}
void main()
{
int i,n,r;
float a,c;
c=0;
a=0;
r=0;
int k[201],m[201];
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&k[i]);
for(i=1;i<=n;i++)
c=(c+k[i]);
c=c/n;
for(i=1;i<=n;i++)
{if ((k[i]>c?(k[i]-c):(c-k[i]))>a) {a=(k[i]>c?(k[i]-c):(c-k[i]));r=1;m[1]=k[i];}
else if((k[i]>c?(k[i]-c):(c-k[i]))==a) {r=r+1;m[r]=k[i];}}
for(i=1;i<=r;i++)
{printf("%d",m[i]);
if(i!=r) printf(",");}
printf("\n");
}
void main()
{ float h,p,q,sum=0.0;
  long int i,n,a[300],max,min;
	scanf("%ld",&n);
	scanf("\n");
	for(i=0;i<n;i++)
		scanf("%ld",&a[i]);
for(i=0;i<n;i++)
{sum=sum+a[i];}
h=sum/n;
max=a[0];
min=a[0];
for(i=0;i<n;i++)
{if(a[i]>max)
max=a[i];
if(a[i]<min)
min=a[i];
}
p=max-h;
q=h-min;
if(p>q)
printf("%ld",max);
if(p<q)
printf("%ld",min);
if(p==q)
printf("%ld,%ld",min,max);
}
int main()
{

	int a[300], n, i,j,sum=0, t;
	float aver, c=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d", &a[i]);
		sum=sum+a[i];
	}
	aver=(float)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;
			}
		}
		if(aver-a[0]>a[n-1]-aver)
			printf("%d",a[0]);
		else if(aver-a[0]<a[n-1]-aver)
			printf("%d",a[n-1]);
		else
			printf("%d,%d",a[0],a[n-1]);


	return 0;
}
int main()
{
	int i,n,m;
	double sum=0,ave=0,max=0,g[1000],s[1000];
	cin>>n;
	for(i=0;i<n;i++)
		cin>>g[i];
	for(i=0;i<n;i++)
		sum=sum+g[i];
	ave=sum/n;
	for(i=0;i<n;i++)
	{
		if((g[i]-ave)>0)
			s[i]=g[i]-ave;
		if((g[i]-ave)<0)
			s[i]=ave-g[i];
	}
	for(i=0;i<n;i++)
	{
		if(s[i]>=max)
		{
			max=s[i];
			m=i;
		}
	}
	for(i=0;i<n;i++)
	{
		if(s[i]==max&&i<m)
			cout<<g[i]<<",";
		if(s[i]==max&&i==m)
			cout<<g[i];
	}
	return 0;
}
int main()
{
	int n,i,j,out[100]={0},k=0,t;
	double average,a[300]={0},s=0,max=0;
	cin>>n;//??n
	for(i=0;i<n;i++)
	{
		cin>>a[i];//??????
		s=s+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;
			}
		}//????
	average=s/n;//?????
	for(i=0;i<n;i++)
	{
		if(fabs(a[i]-average)>max)
		{
			k=0;
			max=fabs(a[i]-average);
			out[k++]=a[i];
		}
		else  if(fabs(a[i]-average)==max)
		{
			out[k++]=a[i];
		}
	}//??????????out???
	for(i=0;i<k;i++)
	{
		if(i==0)cout<<out[i];
		else cout<<','<<out[i];
	}//??
	return 0;
}
int main()
{
    int n,i,j;
    int a[100];
    double max,s,p;
    scanf("%d",&n);
    max=0;
    s=0;
    j=0;
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        s=s+a[i];
    }
    p=s/n;
    for(i=1;i<=n;i++)
        if (fabs(p-a[i])>max)
        {
            max=fabs(p-a[i]);
            j=i;
        }
    if (j!=0)
        printf("%d",a[j]);
    for(i=1;i<=n;i++)
        if (fabs(p-a[i])==max && i!=j)
            printf(",%d",a[i]);
    return 0;
}
/* Name        : ?????
 * Version     : 1.0
 * Date        : 2013-01-12
 * New         : 
 * Description : 
 * State       : Design
 */
int main()
{
    int N=0;
    double Num[300]={0},Diff[300]={0},Extre[300]={0};
    double Average=0,Sum=0;
    double Max=0;
    cin>>N;
    for (int i=0;i<N;i++)
    {
        cin>>Num[i];
        Sum+=Num[i];
    }
    Average=Sum/(double)N;
    for (int i=0;i<N;i++)
    {
        Diff[i]=Num[i]-Average;
        if (Diff[i]<0) Diff[i]=-Diff[i];
        if (Max<Diff[i]) Max=Diff[i];
    }
    int K=0;
    for (int i=0;i<N;i++)
        if (Diff[i]==Max)
        {
            Extre[K]=Num[i];
            K++;
        }
    for (int i=0;i<K;i++)
        for (int k=0;k<K-1;k++)
            if (Extre[k]>Extre[k+1])
            {
                double temp=Extre[k];
                Extre[k]=Extre[k+1];
                Extre[k+1]=temp;
            }
    cout<<Extre[0];
    for (int i=1;i<K;i++) cout<<','<<Extre[i];
    return 0;
}
int main()
{
	unsigned int n,a[300],i,j=0,sum=0,b[300];
	double average,ch,max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	average=(double)sum/n;
	for(i=0;i<n;i++)
	{
		if(a[i]==average)
			continue;
		if(a[i]>average)
			ch=a[i]-average;
		if(a[i]<average)
			ch=average-a[i];
		if(ch==max)
		{
			j++;
			b[j]=a[i];
		}
		if(ch>max)
		{
			j=0;
			max=ch;
			b[j]=a[i];
		}
	}
	for(i=1;i<j;i++)
	{
		int k,t;
		for(k=i;k>0;k--)
		{
			if(b[k]<b[k-1])
			{
				t=b[k];
				b[k]=b[k-1];
				b[k-1]=t;
			}
		}
	}
	printf("%d",b[0]);
	for(i=1;i<=j;i++)
		printf(",%d",b[i]);
	return 0;
}
int main() {
	int n, i, sum = 0, j = 0;
	cin >> n;
	int a[n], c[n];
	for (i = 0; i < n; i++) {
		cin >> a[i];
		sum = sum + a[i];
	}
	double b[n], average = 0, max;
	average = 1.0 * sum / n;
	for (i = 0; i < n; i++) {
		b[i] = fabs(a[i] - average);
	}
	max = b[1];
	for (i = 0; i < n; i++) {
		if (b[i] > max) {
			max = b[i];
		}
	}
	for (i = 0; i < n; i++) {
		if (fabs(b[i] - max) < 1e-6) {
			c[j] = a[i];
			j++;
		}
	}
	if (j == 1) {
		cout << c[0] << endl;
	} else {
		for (i = 0; i < j - 1; i++) {
			cout << c[i] << ",";
		}
		cout << c[j - 1];
	}
	return 0;
}
int main()
{
	int n=0;//??????n
	int a[300],sum=0,t;//????a??????,sum???,t????
	double ave,dis[300],max=0.0;//???????ave?????,??dis??????,max?????????
	cin>>n;
	int i=0,j=0;//??????ij
	int p=0;//p?????
	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=i+1;j<n;j++)
			if(a[i]>a[j])
			{
				t=a[i];
				a[i]=a[j];
				a[j]=t;
			}
	for(i=0;i<n;i++)//?????
		dis[i]=(a[i]-ave)*(a[i]-ave);
	max=dis[0];
	for(i=0;i<n;i++)//??????
		if(dis[i]>=max)
		{
			max=dis[i];
			p++;
		}
	if(p==1)//?????????????
	{
		for(i=0;i<n;i++)
		    if(dis[i]==max)
				cout<<a[i];
	}
	else
		if(p>1)
		{  
		    for(i=0;i<n;i++)
		        if(dis[i]==max)
				{
			       j=i;
			       cout<<a[j];
			       break;
				}
		   for(i=j+1;i<n;i++)
		        if(dis[i]==max)
				   cout<<","<<a[i];
		}
	return 0;
}
void main()
{
	int n, i, j, temp, num=0, *a;
	float ave=0, *depart, max=0;
	scanf("%d",&n);
	a=(int *)malloc(n*sizeof(int));
	depart=(float *)malloc(n*sizeof(float));
	for(i=0; i<n; i++)
	{
		scanf("%d",a+i);
	}
	for(i=n-1; i>0; i--)
	{
		for(j=0; j<i; j++)
		{
			if(*(a+j)>*(a+j+1))
			{
				temp=*(a+j);
				*(a+j)=*(a+j+1);
				*(a+j+1)=temp;
			}
		}
	}
	//for(i=0; i<n; i++) printf("%d\n",*(a+i));
	for(i=0; i<n; i++)
	{
		ave=ave+(float)*(a+i)/n;
	}
	for(i=0; i<n; i++)
	{
		*(depart+i)=ave-*(a+i);
		if(*(depart+i)<0) *(depart+i)=-*(depart+i);
		if(*(depart+i)>max) max=*(depart+i);
	}
	for(i=0; i<n; i++)
	{
		if(fabs(*(depart+i)-max)<1.0e-3) num=num+1;
	}
	//for(i=0; i<n; i++) printf("%f\n",*(depart+i));
	//printf("!!!%f\n",max);
	//printf("%d\n",num);

	for(i=0; i<n; i++)
	{
		if(fabs(*(depart+i)-max)<1.0e-3)
		{
			printf("%d",*(a+i));
			break;
		}
	}
	i=i+1;
	for(; i<n; i++)
	{
		if(fabs(*(depart+i)-max)<1.0e-3)
		{
			printf(",%d",*(a+i));
		}
	}
	
}
/*
 * 1000012889_1.cpp
 *
 *  Created on: 2011-1-9
 *      Author: ???
 *        ??? ?????
 */



int main(){
	int n,i;
	double a,max=0,min=0,sum=0,ave=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a;
		sum+=a;
		if(i==0){
			max=a;
			min=a;
		}
		else{
			if(a>max)
				max=a;
			else if(a<min)
				min=a;
		}
	}
	ave=sum/n;
	if(max-ave>ave-min)
		cout<<max<<endl;
	else if(max-ave<ave-min)
		cout<<min<<endl;
	else
		cout<<min<<','<<max<<endl;
	return 0;
}
int main()
{
	int a[310], n, i, j, temp,  count=0;
	double s = 0,  b[310] = {0}, m;
	cin >> n;

	for(i=0;i<n;i++)
	{
		cin >> a[i];
		s+=a[i];
	}
	for(i=0;i<n-1;i++)
		for(j=0;j<n-1-i;j++)
		{
			if(a[j]>a[j+1])
			{
				temp = a[j];
				a[j] = a[j+1];
				a[j+1] = temp; 
			}
		}
	s = s/n;
	for(i=0;i<n;i++)
	{
		if(a[i]>s)
			b[i] = a[i] - s;
		else
			b[i] = s - a[i];
		if(b[i]>m)
			m = b[i];
	}
	for(i=0;i<n;i++)
	{
		if(b[i]>=m)
			count++;
	}
	for(i=0;i<n;i++)
	{
		if(b[i]>=m)
		{
			count--;
			if(count)
				cout << a[i] << ",";
			else
				cout << a[i] << endl;
		}
	}
	return 0;
	

}
int main()
{
    int n;
    scanf("%d", &n);
    int i;
    int x[100];
    int sum=0;
    for(i=0;i<n;i++)
    {
                    scanf("%d", &x[i]);
                    sum=sum+x[i];
    }
    float aver;
    aver=(float)sum/n;
    float y[100];
    for(i=0;i<n;i++)
    {
                    y[i]=fabs(x[i]-aver);
    }
    float max=y[0];
    for(i=1;i<n;i++)
    {
                    if(y[i]-max>0)
                    {
                                  max=y[i];
                    }
    }
    int z[100];
    int m=0;
    for(i=0;i<n;i++)
    {
                    if(fabs(y[i]-max)<pow(10,-9))
                    {
                               z[m]=x[i];
                               m++;
                    }
    }
    int o,w;
    for(i=1;i<m;i++)
    {
                     for(o=0;o<m-i;o++)
                     {
                                       if(x[o]>x[o+1])
                                       {
                                                      w=z[o];
                                                      z[o]=z[o+1];
                                                      z[o+1]=w;
                                       }
                     }
    }
    
    printf("%d", z[0]);
    for(i=1;i<m;i++)
    {
                    printf(",%d", z[i]);
    }
  
    return 0;
}
int main()
{
    int n,c=0;
	int i,j;
	int a[300];
	scanf("%d",&n);
	for (i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for (i=0;i<n;i++){
		for (j=0;j<n-i-1;j++){
			if (a[j]>a[j+1]){
				int t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;
			}
		}
	}

	double  tot=0;
	for (i=0;i<n;i++){
		tot+=a[i];
	}
	tot=tot/n;
	double cha=0,tt;
	for (i=0;i<n;i++){
		 tt=a[i]-tot;
		if (tt<0){
			tt=-tt;
		}
		if (tt>cha){
			cha=tt;
		}
	}
	for (i=0;i<n;i++){
		tt=a[i]-tot;
		if (tt<0){
			tt=-tt;
		}
		if (cha==tt){
			if (c>0){
				printf(",");
			}
			printf("%d",a[i]);
			c++;
		}
	}
	printf("\n");
    return 0;
}
void main() 
{int n,a[20],s,h=0,i,w=0,max,min; 
float p,q; 
scanf("%d",&n); 
for(i=0;i<n;i++) 
scanf("%d",&a[i]); 
q=(float)n; 
for(i=0,s=0;i<n;i++) 
s=s+a[i]; 
p=s/q; 
min=a[0]; 
for(i=0;i<n;i++) 
if(a[i]<min) 
{ min=a[i];h=i;} 
max=a[0]; 
for(i=0;i<n;i++) 
if(a[i]>max) 
{ max=a[i];w=i;} 
if(fabs(fabs((float)a[h]-p)-fabs((float)a[w]-p))<1e-5) 
printf("%d,%d",a[h],a[w]); 
else if(fabs((float)a[h]-p)>fabs((float)a[w]-p)) 
printf("%d",a[h]); 
else if(fabs((float)a[h]-p)<fabs((float)a[w]-p)) 
printf("%d",a[w]); 
}
int main()
{
	int n,i;
	scanf("%d",&n);
	int an[300]={0},sum=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&an[i]);
        sum+=an[i];
	}
	float average;
	average=sum*1.0/n;
	float away[300]={0};
    for(i=0;i<n;i++)
	{
		if(an[i]-average>=0)
		{
			away[i]=an[i]-average;
		}
		else
		{
			away[i]=average-an[i];
		}
	}
	float f=away[0];
	for(i=1;i<n;i++)
	{
		if(away[i]>=f)
		{
			f=away[i];
		}
	}
	int max[10]={0},j,num=0;
	for(i=0;i<n;i++)
	{
		if(away[i]==f)
		{
			num++;
			max[num]=an[i];
		}
	}
	if(num==1)
		printf("%d",max[1]);
	else 
	{
		for(int m=num-1;m>0;m--)
		{
			for(int n=0;n<m;n++)
				if(max[n]>max[n+1])
				{
					int ntmp=max[n];
					max[n]=max[n+1];
					max[n+1]=ntmp;
				}
		}
		for(int p=1;p<=num;p++)
		{
			printf("%d",max[p]);
			if(p<=num-1)
			printf(",");
		}
	}
	return 0;
}
void main()
{
	int n,i,sum=0,flag=0;float max=0,p;
	int a[300];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	p=(float)sum/n;
	//printf("%f\n",p);
	//printf("%d\n",fabs(a[0]-p));
	for(i=0;i<n;i++)
	{
		if((a[i]-p>max)||(p-a[i]>max))
			max=fabs(a[i]-p);
	}
	//printf("%f\n",max);
	for(i=0;i<n;i++)
	{
		//printf("%f\n%f\n",fabs(a[i]-p)-max,pow(10,-6));
		if(fabs(fabs(a[i]-p)-max)<pow(10,-6))
		{
			if(flag==0) {printf("%d",a[i]);flag=1;}
			else printf(",%d",a[i]);
		}
	}
}
main()
{
	unsigned int n,i,j=0,k,a[310],b[310],t,sum=0;
	float ave,max=0;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	ave=sum/(float)n;
	for (i=0;i<n;i++)
		if (fabs(a[i]-ave)>max) max=fabs(a[i]-ave);
	for (i=0;i<n;i++)
		if (fabs(fabs(a[i]-ave)-max)<0.00001) b[j++]=a[i];
	for (i=0;i<j-1;i++)
		for (k=i+1;k<j;k++)
			if (b[i]>b[k]) 
			{
				t=b[k];
				b[k]=b[i];
				b[i]=t;
			}
	for (i=0;i<j;i++)
	{
		if (i!=0) printf(",");
		printf("%d",b[i]);
	}
	printf("\n");
	return 0;
}
void main()
{	int n,i,num[300],s=0,u=0,m;
	float aver,t[300],max,sum=0,min;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d,",&num[i]);
	for(i=0;i<n;i++)
		sum=sum+(float)(num[i]);
	aver=sum/(float)(n);

	for(i=0;i<n;i++)
	
	t[i]=aver-(float)(num[i]);
	
	min=t[0];
	for(i=0;i<n;i++)
	{if(t[i]>min)
	{min=t[i];
	s=i;
		}
	max=t[0];
	for(m=0;m<n;m++)
	{if(t[m]<max)
	{max=t[m];
	u=m;
		}
	}
	
	}if(t[s]+t[u]<0)
		printf("%d",num[u]);
	else if(t[s]+t[u]>0)
		printf("%d",num[s]);
	else
		printf("%d,%d",num[s],num[u]);


}
main()
{
	int n,i;
	float min,max,a[300],sum,aver;
	scanf("%d",&n);
	scanf("%f",&a[0]);
	min=max=sum=a[0];
    for(i=1;i<n;i++) 
	{
		scanf("%f",&a[i]);
		sum=sum+a[i];
		if(max<a[i]) max=a[i];
		else if(min>a[i]) min=a[i];
	}
	aver=sum/n;
	if(max-aver>aver-min) printf("%.0f",max);
	else if(max-aver<aver-min) printf("%.0f",min);
	else printf("%.0f,%.0f",min,max);
	return 0;
}
float abs(float x);
main()
{
	int input[300],i,flag=-1,num,xiabiao=0;
	float average,sum=0.,fst;
	scanf("%d",&num);
	for(i=0;i<num;i++)
	{
		scanf("%d",&input[i]);
		sum+=input[i];
	}
	average=sum/num;
	fst=abs(input[0]-average);
	for(i=1;i<num;i++)
	{
		if(abs(input[i]-average)>fst){fst=abs(input[i]-average);xiabiao=i;}
	}
	for(i=0;i<num;i++)
		if(abs(input[i]-average)==fst)flag++;
	if(flag==0)printf("%d",input[xiabiao]);
	else
	{
			if(input[xiabiao]<average)
			printf("%d,%d",input[xiabiao],(2*(int)average-input[xiabiao]));
			else 
			printf("%d,%d",(2*(int)average-input[xiabiao]),input[xiabiao]);
	}	
}
float abs(float x)
{
if(x<0)return(-x);
else return(x);
}
int main()
{
	int n, i, j, sum = 0, num[300], flag = 0;
	double temp, average;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> num[i];
		sum += num[i];
	}
	average = (double) sum / n;
	for (i = 0; i < n; i++)
		for (j = 0; j < n - i - 1; j++)
		{
			if (num[j] > num[j+1])
			{
				temp = num[j];
				num[j] = num[j+1];
				num[j+1] = temp;
			}
		}
	temp = fabs (average - num[0]);
	for (i = 1; i < n; i++)
	{
		if (temp < fabs(average - num[i]))
			temp = fabs(average - num[i]);
	}
	for (i = 0; i < n; i++)
	{
		if (fabs((fabs(num[i] - average) - temp)) < 1e-5)
			if (flag == 0)
			{
				cout << num[i];
				flag = 1;
			}
			else
				cout << "," << num[i];
	}
	cout << endl;
	return 0;
}
int a[300];
int n;
float sum=0;
float ave;
int main()
{
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	ave=(float)sum/n;
	void sort();
	sort();
	int flag=0;
	if(ave-a[0]==a[n-1]-ave)
	{
		for(i=0;i<n;i++)
		{
			if(a[i]==a[0]||a[i]==a[n-1])
			{
				if(i!=0)
					printf(",");
				printf("%d",a[i]);
			}
		}
	}
	else if(ave-a[0]>a[n-1]-ave)
	{
		for(i=0;i<n;i++)
		{
			if(a[i]==a[0])
			{
				if(i!=0&&a[i+1]==a[i])
					printf(",");
				printf("%d",a[i]);
			}
		}
	}
	else
	{
		for(i=0;a[i];i++)
		{
			if(a[i]==a[n-1])
			{
                if(flag!=0)
					printf(",");
				printf("%d",a[i]);
				flag=1;
			}
		}
	}
	return 0;
}
void sort()
{
	int i,j;
	for(i=0;i<n-1;i++)
	{
		for(j=i;j<n;j++)
		{
			if(a[i]>a[j])
			{
				int t;
				t=a[i];
				a[i]=a[j];
				a[j]=t;
			}
		}
	}
}
void main()
{
	int n,i,j;
	int a[300];
	float k=0.0,temp,tempo;
	float b[300];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		k=k+a[i];
	}
	k=k/n;
	for(i=0;i<n;i++)
	{
		b[i]=fabs(a[i]-k);
	}
	for(i=0;i<n-1;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(b[i]<b[j])
			{
				temp=a[i];
				a[i]=a[j];
				a[j]=temp;
				tempo=b[i];
				b[i]=b[j];
				b[j]=tempo;

			}
		}
	}
	printf("%d",a[0]);
	for(i=1;i<n;i++)
	{
		if(b[i]==b[0])
			printf(",%d",a[i]);
	}

}