semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
void main()
{
	int m,n,i,a[301],sum,max,min;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	sum=0;max=a[0];min=a[0];
	for (i=0;i<n;i++)
	{
		sum+=a[i];
		if (a[i]>max) max=a[i];
		if (a[i]<min) min=a[i];
	}
	max*=n;min*=n;
	if ((max-sum)>(sum-min)) printf("%d",max/n);
	if ((max-sum)<(sum-min)) printf("%d",min/n);
	if ((max-sum)==(sum-min)) printf("%d,%d",min/n,max/n);
}
float gap(int x,float y){
	float z;
	if(x>y)z=x-y;
	else z=y-x;
	return z;
}
void main(){ 
    int num[300];
	float g;
	int n,i,j=0;
	float ave=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&num[i]);
		ave+=num[i];
	}
	ave=ave/n;
	for(i=0;i<n-1;i++){
		if (gap(num[i],ave)<gap(num[i+1],ave) && gap(num[i+1],ave)>g)g=gap(num[i+1],ave);
		if (gap(num[i],ave)>gap(num[i+1],ave) && gap(num[i],ave)>g)g=gap(num[i],ave);
	}
	for(i=0;i<n;i++){
		if(gap(num[i],ave)==g){
			printf("%d",num[i]);
			j=i+1;
			break;}
	}
	for(i=j;i<n;i++)if(gap(num[i],ave)==g)printf(",%d",num[i]);
}
void main()
{
	int n,a[300],b[300],i,s=0,k=0,j,t;
	double x,y;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++)
	{
		s=s+a[i];
	}
	x=(double)s/(double)n;
	y=fabs(a[0]-x);
	for(i=1;i<n;i++)
		if(fabs(a[i]-x)>y)
			y=fabs(a[i]-x);
	for(i=0;i<n;i++)
		if(fabs(a[i]-x)==y)
		{
			b[k]=a[i];
			k++;
		}
	if(k==1)
		printf("%d",b[0]);
	else if(k==2)
	{
		if(b[0]>b[1])
			printf("%d,%d",b[1],b[0]);
		else printf("%d,%d",b[0],b[1]);
	}
	else
	{
		for(j=0;j<k-1;j++)
			for(i=0;i<k-1-j;i++)
				if(b[i]>b[i+1])
				{
					t=b[i];
					b[i]=b[i+1];
					b[i+1]=t;
				}
		printf("%d",b[0]);
		for(i=1;i<k;i++)
			printf(",%d",b[i]);
	}
}
int main()
{
	int n,i,j;
	double sum=0,ave=0;
	double a[300];
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		sum=sum+a[i];
	}
	ave=sum/n;
	double dis[300];
	for(i=0;i<n;i++)
	{
		dis[i]=fabs(a[i]-ave);
	}
	double max=0;
	for(i=0;i<n;i++)
	{
		if(dis[i]>max)
			max=dis[i];
	}
	double b[300]={0};
	int k=0,temp=0;
	for(i=0;i<n;i++)
	{
		if(fabs(dis[i]-max)<0.01)
		{
			b[k]=a[i];
			k++;
		}
	}
	if(k==1){cout<<b[0];}
	else{
	for(i=0;i<k;i++)
	{
		for(j=i+1;j<k;j++)
		{
			if(b[i]>b[j])
			{
				temp=b[i];
				b[i]=b[j];
				b[j]=temp;
			}
		}
	}
	cout<<b[0];
	for(i=1;i<k;i++)
		cout<<","<<b[i];}
	return 0;
}
float k( float i)
{
	if(i>=0)
		return i;
	else return -i;
}
void main()
{
	int n,a[400],s=0,max=0,min,count=0,i;
	float aver;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		s=s+a[i];
	}
	aver=((float)s)/n;
	for(i=0,min=a[0];i<n;i++)
	{
		if(a[i]>max)
			max=a[i];
		if(a[i]<min)
			min=a[i];
	}
	if(((float)max-aver)>(-(float)min+aver))
		printf("%d",max);
    if(((float)max-aver)<(-(float)min+aver))
		printf("%d",min);
	if(((float)max-aver)==(-(float)min+aver))
		printf("%d,%d",min,max);
}
int main()
{
    int n;
    float pj=0,max=0,b[300],a[300],sum=0;
    int c[300]={0};
    int i=0,j=0,k=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum=sum+a[i];
    }
    pj=sum/n;
    for(i=0;i<n;i++)
    {
        if((pj-a[i])>0) b[i]=pj-a[i];
        else b[i]=a[i]-pj;
    }
    for(i=0;i<n;i++)
    {
        if(b[i]>max) max=b[i];
    }
    for(i=0;i<n;i++)
    {
        if(b[i]==max)
        {
            c[k]=i;
            k++;
        }
    }
    for(i=0;i<(k-1);i++)
    for(j=0;j<(k-i-1);j++)
    if(a[c[j]]>a[c[j+1]]) swap(a[c[j]],a[c[j+1]]);
    for(i=0;i<k-1;i++)
        cout<<a[c[i]]<<",";
        cout<<a[c[k-1]];
    
    return 0;
}
void main()
{
	float num[300];
	int n,i,j;
	float temp;
	float max1,max2;
	float a,sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%f",&num[i]);
	for(i=0;i<n;i++)
		sum=sum+num[i];
	a=sum/(float)n;
	for(i=0;i<n;i++)
	{	for(j=0;j<n-i-1;j++)
			if(num[i]>num[i+1])
			{
				temp=num[i];
				num[i]=num[i+1];
				num[i+1]=temp;
			}
	}

	max1=num[0];
	for(i=1;num[i]<a;i++)
	{
		if((a-num[i])>(a-max1))
			max1=num[i];
	}
	max2=num[n-1];
	for(i=n-1;num[i]>a;i++)
	{
		if((num[i]-a)>(a-max2))
			max2=num[i];
	}
	if((a-max1)==(max2-a))
		printf("%.0f,%.0f",max1,max2);
	else if((a-max1)>(max2-a))
		printf("%.0f",max1);
	else
		printf("%.0f",max2);
	
}
int main()
{
	int num[301],change[301];
	int n=0,i=0,sum=0,count=0;
	double ave=0,max=0;
	memset(num,0,sizeof(num));
	memset(change,0,sizeof(change));
	cin>>n;
	for(i=0;i<n;i++)
		cin>>num[i];
	for(i=0;i<n;i++)
		sum=sum+num[i];
	ave=(double)sum/n;
	for(i=0;i<n;i++)
		if(fabs(num[i]-ave)>max)
			max=fabs(num[i]-ave);
	for(i=0;i<n;i++)
		if(fabs(fabs(num[i]-ave)-max)<0.00001)
		{
			change[count]=num[i];
			count++;
		}
	if(count==2)
	{
		if(change[1]>change[0])
			cout<<change[0]<<","<<change[1];
		else
			cout<<change[1]<<","<<change[0];
	}
	else
		cout<<change[0];
	return 0;
}
main()
{
	int n,i,sum=0,c,d=0,x=0;
	struct s
	{
		int n;
		int c;
	}t[300];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&t[i].n);
		sum+=t[i].n;
	}
	for(i=0;i<n;i++)
	{
		t[i].c=sum-t[i].n*n;
		if(t[i].c<0)
			t[i].c=-t[i].c;
		if(t[i].c>c)
			c=t[i].c;
	}
	for(i=0;i<n;i++)
	{
		if(t[i].c==c)
		{
			if(t[i].n*n<=sum)
			{
				x++;
			}
			else
				d++;
		}
	}
	if(d!=0)
	{
			for(i=0;i<x;i++)
	{
		printf("%d,",(sum-c)/n);
	}
	for(i=0;i<d;i++)
	{
		printf("%d",(sum+c)/n);
		if(i<d-1)
			printf(",");
	}
	}
	else
		for(i=0;i<x;i++)
		{
			printf("%d",(sum-c)/n);
			if(i<x-1)
				printf(",");
		}
}
int main()
{
	int n,i,j,t;
	cin>>n;
	int x[n+1];
	double dif[n+1], ave,sum=0,max=0; 
	for(i=1;i<n+1;i++)
	{
		cin>>x[i];
		sum=sum+x[i]; 
	}
	ave=sum/n;
	for(i=1;i<n+1;i++)
	{
		for(j=i;j<n+1;j++)
		{
			if(x[j]<x[i])
			{
				t=x[i];
				x[i]=x[j];
				x[j]=t;
			}
		}
	}
	for(i=1;i<n+1;i++)
	{
		dif[i]=x[i]-ave;
		if(dif[i]<0) dif[i]=-dif[i];
		if(dif[i]>max) max=dif[i];
	}
	int flag=0;
	for(i=1;i<n+1;i++)
	{
		if(dif[i]==max)
		{
			if(flag==0) 
			{
				cout<<x[i];
				flag++;
			}
			else cout<<","<<x[i];
		}
	}
	return 0;
}
int main()
{
	int n,a[400],i,j,b[400],count=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	double sum=0,ave,max=0;
	for(i=1;i<=n;i++)
	{
		sum+=a[i];
	}
	ave=sum/n;
	for(i=1;i<=n;i++)
	{
		if(fabs(ave-(double)a[i])>max)
		{
			max=fabs(ave-(double)a[i]);
		}
	}
	for(i=1;i<=n;i++)
	{
		if(max-fabs(ave-(double)a[i])<0.0001)
		{
			count++;
			b[count]=a[i];
		}
	}
	if(count==1)
	{
		
		cout<<b[1];
	}
	else
	{
		for(i=count;i>0;i--)
		{
			for(j=1;j<i;j++)
			{
				if(b[j]>b[j+1])
				{
					swap(b[j],b[j+1]);
				}
			}
		}
		for(i=1;i<count;i++)
		    cout<<b[i]<<',';
	    cout<<b[count];
	}
	
	return 0;
}
int main()
{
	int n,i, k,j=0,p;
	float average,a[100],sum=0,c[100],d[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%f",&a[i]);
	}
	for(i=0;i<n-1;i++)
	{
		for(k=0;k<n-i-1;k++)
		{
			if(a[i]>a[i+1])
			{
				float t=0;
				t=a[i];
				a[i]=a[i+1];
				a[i+1]=t;
			}
		}
	}
	for(i=0;i<n;i++)
	{
		sum+=a[i];
	}
	average=sum/n;
	for(i=0;i<n;i++)
	{
		c[i]=average-a[i];
		if(c[i]<0)
		{
			c[i]=a[i]-average;
		}
	}
	float max=0;
	for(i=0;i<n;i++)
	{
		if(c[i]>max)
		{
			max=c[i];
		}
	}
	for(i=0;i<n;i++)
	{
		if(c[i]==max)
		{
		      d[j]=a[i];
                         j++;
		}
		
	}
         if(j==1)
         {
              printf("%.0f", d[j-1]);
           }
          else if(j>1)
          {
                 for(p=0;p<j-1;p++)
                 {
                   printf("%.0f,", d[p]);
                 }                  
                 printf("%.0f",d[j-1]);
            }
	return 0;


		
}
int main( int argc, char* argv[] ){
	int count, sentry = 0;
	int * values;
	int i, sum = 0;
	double ave, temp, distance = 0;
	int * mid;

	scanf ( " %d ", &count );
	values = ( int * )malloc( count * sizeof(int) );
	mid = ( int * )malloc( count * sizeof(int) );
	for ( i = 0; i < count; i++ ){
		scanf ( "%d", (values + i) );
		sum += *( values + i );
	}
	
	ave = 1.0 * sum / count;
	
	for ( i = 0; i < count; i++ ){
		temp = fabs( 1.0 * values[i] - ave );
		if ( temp > distance ){
			distance = temp;
			mid[0] = values[i];
			sentry = 0;
		}
		else if ( temp == distance ){
			sentry++;
			mid[sentry] = values[i];
		}
	}

	
	printf( "%d", mid[0] );


	for ( i = 1; i <= sentry; i++ ){
		printf( ",%d", mid[i]);
	}
	return 0;
}
int main()
{
	int n;
	int a[300];
	cin>>n;
	int i,j;
	float average=0;
	for(i=0;i<=n-1;i++)
	{
		cin>>a[i];
		average+=a[i];
	}
	average/=n;
	for(i=0;i<=n-2;i++)
		for(j=n-1;j>=i+1;j--)
		{
			if(a[j]<a[j-1]){
				int t=a[j];
				a[j]=a[j-1];
				a[j-1]=t;
			}
		}
	float s=(average-a[0])-(a[n-1]-average);
	if(s>0)cout<<a[0];
	else if(s<0)cout<<a[n-1];
	else cout<<a[0]<<','<<a[n-1];
	return 0;
}
int main(){
	int n;
	scanf("%d",&n);
	int sz[LEN];
	int sum=0;
	for(int i=0;i<n;i++){
		scanf("%d",&sz[i]);
		sum+=sz[i];
	}
	double junzhi;
	junzhi=1.0*sum/n;
	int min=sz[0];
	int max=sz[0];
	for(int r=0;r<n;r++){
		if(sz[r]>max){
			max=sz[r];
		}
		if(sz[r]<min){
			min=sz[r];
		}
	}
	if(1.0*(max+min)/2==junzhi){
		printf("%d,%d",min,max);
	}else if(junzhi-min>max-junzhi){
		printf("%d",min);
	}else{
		printf("%d",max);
	}
	return 0;
}
int main(int argc, char* argv[])
{
	int n,i,sum=0;
	scanf("%d",&n);
	int *a;
	a = (int *)malloc(sizeof(int)*n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	double aver=sum*1.0/(n*1.0);
	double *c;
	c = (double *)malloc(sizeof(double)*n);
	for(i=0;i<n;i++){
		c[i]=fabs(a[i]*1.0-aver);
	}
	int d=0;
	double max=c[0];
	for(i=0;i<n;i++){
		if(max<c[i]){
			max=c[i];
			d=i;
		}
	}
	int b=0;
	for(i=0;i<n;i++){
		if(c[i]==max)
			b++;
	}
	printf("%d",a[d]);
	if(b!=1){
		for(i=d+1;i<n;i++){
			if(c[i]==max)
				printf(",%d",a[i]);
		}
	}
    return 0;
}
int main()
{

  int n,i,k=0;
  scanf("%d",&n);
  float x,nu[300];
  float d=0;
  float z=0;
  float nn[300];
  for(i=0;i<n;i++)
  {
  scanf("%f",&nu[i]);
  z=z+nu[i];
  
  }
  x=z/(float)n;
  for(i=0;i<n;i++)
  {
    if(x-nu[i]>d)
	{	d=x-nu[i];}
	if(nu[i]-x>d)
	{	d=nu[i]-x;}
  }
  for(i=0;i<n;i++)
  {
      if(x-nu[i]-d<=0.01&&x-nu[i]-d>=-0.01)
	  {
		  nn[k]=nu[i];
	      k++;
	  }
	  else
		  if(nu[i]-x-d<=0.01&&nu[i]-x-d>=-0.01)
		  { nn[k]=nu[i];
	      k++;}
  
  
  }
  printf("%.0f",nn[0]);
  for(i=1;i<k;i++)
  {
  printf(",%.0f",nn[i]);
  }


  return 0;
}
void main()
{
	int i,n,a[300],*p[300],j=0,j1,j2,*temp;
	double aver=0,max=0;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		aver=aver+a[i];
	}
	aver/=n;
	for (i=0;i<n;i++)
		max=fabs(aver-a[i])>max?fabs(aver-a[i]):max;
	for (i=0;i<n;i++)
		if (fabs(fabs(aver-a[i])-max)<1e-6) 
		{
			p[j]=&a[i];
			j++;
		}
	for (j1=0;j1<j-1;j1++)
		for (j2=0;j2<j-1-j1;j2++)
			if (*p[j2]>*p[j2+1])
			{
				p[j2]=temp;
				p[j2]=p[j2+1];
				p[j2+1]=temp;
			}
	printf("%d",*p[0]);
	for (j1=1;j1<j;j1++)
		printf(",%d",*p[j1]);
}
int main()
{
	int a[300];
	double b[300];
	int n;
	int i,j;
	double zong=0;
	double max=0;
	double ping;
	scanf("%d",&n);
	for(i=0;i<=n-1;i++)
	{
		scanf("%d",&a[i]);
		zong=zong+a[i];
	}
	ping=zong/n;
	for(i=0;i<=n-1;i++)
	{
		if(ping-a[i]>=0)
			b[i]=ping-a[i];
		else
			b[i]=a[i]-ping;
	}
	for(i=0;i<=n-1;i++)
	{
		if(b[i]>max)
		{
			max=b[i];
		}
	}
	for(i=0,j=0;i<=n-1;i++)
	{
		if(b[i]==max)
		{
			j++;
			if(j==1)
				printf("%d",a[i]);
			else
				printf(",%d",a[i]);
		}
	}
	printf("\n");
	return 0;
}
int main()
{
	int n,i,j,temp,a[300],sum=0;
	double t,b[300],max;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	    t=1.0*sum/n;
	for(i=0;i<n-1;i++)
	{
		for(j=n-1;j>i;j--)
		{
			if(a[i]>a[j])
			{
				temp=a[i];
				a[i]=a[j];
                a[j]=temp;
			}
		}
	}

	for(j=0;j<n;j++)
	{
		if(a[j]>=t)
		{
			b[j]=a[j]-t;
		}
		else
		{
			b[j]=t-a[j];
		}
		 max=b[0];
	    if(b[j]>=max)
		{
			max=b[j];
		}
		else if(b[j]<max)
		{
			max=b[0];
		}
	    
	}
	int mm = 0;
	for(j=0;j<n;j++)
	{

		if (max == b[j])
		{
			if ( mm == 0)
			{
				printf("%d",a[j]);
			}
			else 
			{
				printf(",%d",a[j]);
			}
			mm++;
		}
	}
	
		return 0;
}
int main()
{
	int n, a[300], flag = 0, i;
	double ave, sum = 0, max = 0;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	ave = sum / n;
	for (i = 0; i < n; i++)
		if (fabs(a[i] - ave) - max > 1e-5)
			max = fabs(a[i] - ave);
	for (i = 0; i < n; i++)
		if (fabs(fabs(a[i] - ave) - max) < 1e-5 && flag == 0)
		{
			cout << a[i];
			flag = 1;
		}
		else if (fabs(fabs(a[i] - ave) - max) < 1e-5 && flag == 1)
			cout << ',' << a[i];
	return 0;
}
void main()
{
	int n;
	int sum;
	int a[300],i;
	float b[300],ave;
	float c,d;
	sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	c=sum;d=n;
	ave=c/d;
	for(i=0;i<n;i++)
	{
		if(a[i]>ave)
			b[i]=a[i]-ave;
		else b[i]=ave-a[i];
	}
	int flag;
	flag=0;
	for(i=0;i<n;i++)
	{
		if(b[i]>b[flag])
			flag=i;
	}
	int flags;
	flags=(-1);
	for(i=0;i<n;i++)
	{
		if(b[i]==b[flag]&&i!=flag)
			flags=i;
	}
	if(flags==(-1))
		printf("%d",a[flag]);
	else 
	{
		if(a[flag]>a[flags])
			printf("%d,%d",a[flags],a[flag]);
		else printf("%d,%d",a[flag],a[flags]);
	}
}
struct A
{
    double data;
    double differences;
}a[300+10],temp;

int n;

double getaverage(int n)
{
    double sum=0;
    for(int i=0;i<=n-1;i++)
    sum+=a[i].data;
    return sum/n;
}
int main()
{
    cin>>n;
    for(int i=0;i<=n-1;i++)
    cin>>a[i].data;
    double average=getaverage(n);
    for(int i=0;i<=n-1;i++)
    {
        a[i].differences=a[i].data-average;
        if(a[i].differences<0)
        {
            a[i].differences=-a[i].differences;
        }
    }
    for(int i=0;i<=n-1;i++)
        for(int j=n-1;j>i;j--)
        {
            if(a[i].differences<a[j].differences)
            {
                temp=a[i];
                a[i]=a[j];
                a[j]=temp;
            }
        }
    double output[300+10];
    output[0]=a[0].data;
    int k=0;
    for(int i=1;i<=n-1;i++)
    {
        if(a[i].differences==a[0].differences)
        output[++k]=a[i].data;
    }

    for(int i=0;i<=k;i++)
        for(int j=k;j>=i;j--)
        {
            if(output[i]>output[j])
            {
                double temp1=output[i];
                output[i]=output[j];
                output[j]=temp1;
            }
        }

    for(int i=0;i<=k-1;i++)
    cout<<output[i]<<",";
    cout<<output[k]<<endl;

    return 0;
}
/*
 * 1.cpp
 *
 *  Created on: 2011-1-9
 *      Author: jsgl
 */


int main(){
	int n,i,sum=0,num=1;
	int a[500];
	double aver,c;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	aver=1.0*sum/n;
	c=abs(aver-a[0]);
	for(i=1;i<n;i++){
		if(abs(aver-a[i])==c)
			num++;
		if(abs(aver-a[i])>c){
			c=abs(aver-a[i]);
			num=1;
		}
	}
	if(num==1)
		for(i=0;i<n;i++)
			if(c==abs(aver-a[i]))
				cout<<a[i];
	if(num>1){
		int g=0,h=0;
		for(i=0;i<n;i++)
			if(c==(aver-a[i])){
				g=1;
				cout<<a[i];
				break;
			}
		i++;
		for(;i<n;i++)
			if(c==(aver-a[i]))
				cout<<","<<a[i];
		if(g!=1){
			for(i=0;i<n;i++)
				if(c==(a[i]-aver)){
					h=1;
					cout<<a[i];
					break;
				}
		}
		if(h==1)i++;
		if(g==1)i=0;
		for(;i<n;i++)
			if(c==(a[i]-aver))
				cout<<","<<a[i];
			}
	return 0;
}
int main()
{
	int n,i,t,num[300],sum=0,k,m;
	float a,c[300],mc=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&t);
		num[i]=t;
		sum+=num[i];
	}
	a=(float)sum/(float)n;
	for(i=0;i<n;i++){
		if(num[i]>a)
			c[i]=(float)num[i]-a;
		else
			c[i]=a-(float)num[i];
	}
	for(i=0;i<n;i++){
		if(c[i]>mc){
			mc=c[i];
			k=i;
		}
	}
	for(i=0;i<n;i++){
		if(c[i]>=mc){
			mc=c[i];
			m=i;
		}
	}
	if(m==k)
		printf("%d",num[k]);
	else if(num[k]>num[m])
		printf("%d,%d",num[m],num[k]);
	else
		printf("%d,%d",num[k],num[m]);
	return 0;
}
int n,i;
long int rec[301];
long int min,max;
float sum;
main()
{
	scanf("%d\n",&n);
	sum=0;
	min=100000; 
	max=0;
	for(i=1;i<=n;i++) 
	{
		scanf("%d",&rec[i]);
		sum=sum+rec[i];
		if (rec[i]<min) min= rec[i];
		if (rec[i]>max) max=rec[i];
	}
	sum=sum/n;
	if (max-sum==sum-min) printf("%d,%d\n",min,max);
	else if (max-sum>sum-min) printf("%d\n",max);
	else printf("%d\n",min);
}
int main()
{
	int n, i,  k;
	double t;
	double b[300] = {0};
	double a[300];
	cin >> n;
	double num, sum = 0;
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
		sum = sum + a[i];
	}
	
	num = sum / n;
	double max = 0;
	
	for (i = 0; i < n; i++)
	{
		if (fabs(num - a[i]) > max)
		{
			max = fabs(num - a[i]);
			
		}
	}
	int j = 0;
	for (i = 0; i < n; i++)
	{	
		double cha = fabs(num - a[i]);
		if (cha - max == 0 )
		{  
			b[j] = a[i]; 
			j++;
		}
	}
	
	for (i = 0; i < j - 1; i++)
		for (k = 0; k < j-i-1; k++)
		{
			if (b[k] > b[k+1])
			{
				t= b[k];
				b[k] = b[k+1];
				b[k+1] = t;
			}
		}
	
	for (i = 0; i < j-1; i++)
		cout << b[i]<<",";
	cout << b[j-1];
	return 0;
	}
int main()
{
    int n;
    cin >> n;

    int iin[100];
    int counter = 0;
    for(int i = 0; i < n; i++){
        cin >> iin[i];
        counter = counter + iin[i];
    }

    //cout << counter << endl;

    int buffer = 0;
    for(int i = 0; i < n; i++){
        if(abs((iin[i]*n-counter))>buffer)
            buffer = abs(iin[i]*n-counter);
    }

    //cout << buffer << endl;

    for(int i = 0; i < n-1; i++){
        for(int j = i; j < n; j++){
            if(buffer==abs(iin[i]*n-counter)&&buffer==abs(iin[i]*n-counter)&&(iin[i]>iin[j]))
                swap(iin[i],iin[j]);
        }
    }

    int buffer2 = 0;
    for(int i = 0; i < n; i++){
        if(buffer==abs(iin[i]*n-counter))
            buffer2++;
    }

    for(int i = 0; i < n; i++){
        if(buffer==abs(iin[i]*n-counter)&&buffer2!=1){
            buffer2--;
            cout << iin[i] << ',';
            continue;
        }
        if(buffer==abs(iin[i]*n-counter)&&buffer2==1){
            cout << iin[i];
        }
    }
    return 0;
}
float absd(float a)
{
	if (a<0)
		a=-a;
	return(a);
}
void main()
{   
	float ave,num,s;
	int m,j,k,i,a[300]={0};
	scanf("%d",&m);
	s=0;
	for(i=0;i<m;i++)
	scanf("%d",&a[i]);
    for(i=0;i<m;i++)
		s=s+a[i];
	ave=s/m;
	num=absd(a[0]-ave);
	k=a[0];j=0;
	for (i=1;i<m;i++)
	{
		if (absd(ave-a[i])>num)
		{
		  num=absd(ave-a[i]);
		  k=a[i];
		}
	    else
		  if(absd(ave-a[i])==num)
            j=a[i];
    }
		  if(j==0)
		printf("%d",k);
	else
		if(k>j)
			printf("%d,%d",j,k);
		else
            printf("%d,%d",k,j);

}
float f(float a[],int n)
{
	float s=0;
	int i;
	for(i=0;i<=n-1;i++)
	{
		s=s+a[i];
	}
	return s/n;
}
float g(float a)
{
	if(a>0)
		return a;
	else
		return -a;
}
void main()
{
	float a[100],b[100],c=0,d,t,m[100];
	int n,i,j,k=0;
	scanf("%d",&n);
	for(i=0;i<=n-1;i++)
		scanf("%f",&a[i]);
	for(i=0;i<=n-1;i++)
	{
		for(j=n-2;j>=i;j--)
		{
			if(a[j+1]<a[j])
			{
				t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;
			}
		}
	}

	d=f(a,n);
	for(i=0;i<=n-1;i++)
	{
		b[i]=g((d-a[i]));
		if(b[i]>c)
			c=b[i];
	}
	for(i=0;i<=n-1;i++)
	{
		if(b[i]==c)
		{
			m[k]=a[i];
			k++;
		}
	}
	if(k==1)
		printf("%.0f",m[0]);
	else
	{
		for(i=0;i<=k-2;i++)
			printf("%.0f,",m[i]);
		printf("%.0f",m[k-1]);
	}

}
//********************************
//* ??? ?????                      
//* ?????                   *
//********************************
int main()
{
	int n;
	cin>>n;
	int a[301]={0};
	int i,j,temp=0;
	double t=0;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		t+=a[i];
	}
	double avrage=t/n;
	double b[301]={0};
	for(i=0;i<n;i++)
		b[i]=fabs(a[i]-avrage);
	t=0;
	double c[301]={0};
	int k=0;
	for(i=0;i<n;i++)
		if(b[i]>t)
			t=b[i];
	for(i=0;i<n;i++)
		if(b[i]==t)
		{
			c[k]=a[i];
			k++;
		}
	for(i=1;i<=k-2;i++)
		for(j=0;j<=k-1-i;j++)
		{
			if(c[j]>c[j+1])
			{
				t=c[j];
				c[j]=c[j+1];
				c[j+1]=t;
			}
		}
		for(i=0;i<k;i++)
		{
			if(i==0)
				cout<<c[i];
			else
				cout<<","<<c[i];
}
	return 0;
}
void sort(int min[],int n);
void main()
{
	int a[300],n,i,j=0,sum=0,min[300],m;
	float av,b[300];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	av=(float)sum/(float)n;
	for(i=0;i<n;i++)
	{
		if(a[i]>av)
		b[i]=a[i]-av;
		else
		b[i]=av-a[i];
	}
	m=0;
	for(i=0;i<n;i++)
		if(b[m]<b[i])
			m=i;
	for(i=0;i<n;i++)
		if(b[i]==b[m])
			min[j++]=a[i];
	{
	int i,x,t;
	for(i=0;i<j-1;i++)
		for(x=0;x<j-i-1;x++)
			if(min[x]>min[x+1])
			{
				t=min[x];
				min[x]=min[x+1];
				min[x+1]=t;
			}
	}
	for(i=0;i<j;i++)
	{
		printf("%d",min[i]);
		if(i!=j-1)
			printf(",");
	}

}
int main()
{
	int b[max]={0},x;
	int n,i,j,a[max]={0},sum=0,r=0,tem;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	for(i=0;i<n;i++)
		for(j=0;j<n-1-i;j++)
		{
			if(a[j]>a[j+1])
			{
				tem=a[j];
				a[j]=a[j+1];
				a[j+1]=tem;
			}
		}
	for(i=0;i<n;i++)
		b[i]=fabs(a[i]*n-sum);
	x=b[0];
	for(i=0;i<n;i++)
		if(b[i]>x)
			x=b[i];
	for(i=0;i<n;i++)
	{
		if(b[i]==x)
		{
			if(r==0)
				printf("%d",a[i]);
			else
				printf(",%d",a[i]);
			r++;
		}
	}
	return 0;
}
int a[305];
int n;
double s;
double ave;
int minn, maxn;
int ans[305], num;
int main()
{
	cin >> n;
	s = 0;
	num = 0;
	cin >> a[0];
	s += a[0];
	minn = a[0]; maxn = a[0];
	for( int i = 1;i < n; i++ )
	{
			cin >> a[i];
			s += a[i];	
			if(minn > a[i]) minn = a[i];
			if(maxn < a[i]) maxn = a[i];
	}
	ave = s / n;
	double t1, t2;
	t1 = ave - minn;
	t2 = maxn - ave;
	if(t1 > t2)
		cout << minn <<endl;
	else if(t1 < t2)
		cout << maxn <<endl;
	else
		cout << minn <<","<< maxn <<endl;
	return 0;
}
int main()
{
	int n,i,j,m;
	cin>>n;
	
	float s,b[350],p,a[350],c[350];
	s=0;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		s=s+a[i];
	}
	s=s/n;
	for(i=0;i<n;i++)
	{
		b[i]=a[i]-s;
		b[i]=abs(b[i]);
	}
	p=b[0];
	for(i=0;i<n;i++)
	{
		if(p<b[i])
			p=b[i];
	}
	j=0;
	for(i=0;i<n;i++)
	{
		if(p==b[i])
		{
			c[j]=a[i];
			j=j+1;
			
		}
	}
	for(i=0;i<j;i++)
		for(m=0;m<j-i-1;m++)
		{
			if(c[m]>c[m+1])
			{
				p=c[m];
				c[m]=c[m+1];
				c[m+1]=p;
			}
		}
	cout<<c[0];
	for(i=1;i<j;i++)
		cout<<","<<c[i];
	return 0;
}
void main()
{int n,i,j,k,t,max,min,pian,a[300],all,b[20];
 scanf("%d",&n);
 for(i=0;i<n;i++)
   scanf("%d",&a[i]);
 min=a[0];
 max=a[0];
 all=a[0];
 for(i=1;i<n;i++)
   {all=all+a[i];
    if(a[i]>max)
        max=a[i];
    if(a[i]<min)
        min=a[i];
   }
 min=min*n;
 max=max*n;
 pian=(max-all)>(all-min)?(max-all):(all-min);
 j=0;
 for(i=0;i<n;i++)
    if(((a[i]*n-all)==pian)||((a[i]*n-all)==(-pian)))
        {b[j]=a[i];
         j++;}
 
 for(i=0;i<j;i++)
      for(k=i+1;k<j;k++)
           if(b[k]<b[i])
               {t=b[i];
                b[i]=b[k];
                b[k]=t;
               }
 printf("%d",b[0]);
 for(i=1;i<j;i++)
       printf(",%d",b[i]);
}
int main()
{int i,j,k,temp=0,n,x[301],y[301];
 float ave=0,max=0;
 scanf("%d",&n);
 for (i=0;i<n;i++)
 {scanf("%d",&x[i]);
 ave=x[i]+ave;}
 ave=ave/n;
 for (i=0;i<n;i++)
	 if(fabs(ave-x[i])>max)
	   max=fabs(ave-x[i]);
 for (i=0,j=0;i<n;i++)	 
    if (fabs(ave-x[i])>max-0.01)
	{y[j]=x[i];j++;}
 k=j-1;
 for (i=1;i<=n;i++)
	for(j=0;j<k;j++)
	 {if(y[j]>y[j+1])
	    {temp=y[j];
	     y[j]=y[j+1];
		 y[j+1]=temp;
	 }}
	printf("%d",y[0]);
 for (i=1;i<=k;i++)
	 printf(",%d",y[i]);
return 0;
 
}
int main()
{
	int n;
	float m,max=0,min=1000000,sum=0,ave;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>m;
		sum+=m;
		if(max<m)
			max=m;
		if(min>m)
			min=m;
	}
	ave=sum/n;
	if(2*ave<max+min)
		cout<<max<<endl;
	else if(2*ave>max+min)
		cout<<min<<endl;
	else
		cout<<min<<","<<max<<endl;
	return 0;
}
int main()
{ void pai(double a[],int n,double c[]);
  double a[100]={0},sum=0,ave=0,b[100]={0};
  int i=0,n=0,c[100]={0},k=1;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  { scanf("%lf",&a[i]);
    sum=sum+a[i];
  
		}
		ave=sum/n;
	for(i=0;i<n;i++)
	{ b[i]=fabs(a[i]-ave);
	  
		
		}
	pai(b,n,a);
	for(i=0;i<n;i++)
	{ if(b[i]==b[i+1])
	   k=k+1;
	   else break;	  	  
		}
	pai(a,k,b);
	for(i=k-1;i>=0;i--)
	{ printf("%d",(int)a[i]);
	  if(i>0)
	   printf(",");
		}
		return(0);
}
void pai(double a[],int n,double c[])
{ double t=0;
  int i=0,t1=0,j=0;
  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;
           t=c[j];
           c[j]=c[j+1];
           c[j+1]=t;
				}
			}
		}
}
void main()
{
	int n,i,a[300],sum=0,k[300],m=0,j;
	double ave,c[300],d;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++){sum=sum+a[i];}
	ave=1.0*sum/n;
	for(i=0;i<n;i++){
		if(a[i]*1.0-ave>=0){c[i]=a[i]*1.0-ave;}
		else{c[i]=ave-a[i]*1.0;}
	}
	d=c[0];
	for(i=1;i<n;i++){
		if(d<c[i]){d=c[i];}
	}
	for(i=0;i<n;i++){

		if(c[i] == d){
			k[m] = a[i];
			m++;
		}
	
/*		if(a[i]*1.0-ave>=0){
			if(d==a[i]*1.0-ave)
			{
				k[m]=a[i];m=m+1;
			}
		}
		else {
			if(d==ave-a[i]*1.0)
			{
				k[m]=a[i];m=m+1;
			}
		}*/
	}


	if(m==1){printf("%d",k[0]);}
	else if(m>1){
		for(j=0;j<m-1;j++){printf("%d,",k[j]);}
		printf("%d",k[m-1]);
	}





	
}