void main()
{
	int i,j,a;
	char c,str[800],substr[4],str0[800],max;
	while((scanf("%s %s",str,substr))!=EOF)
	{
		a=strlen(str);
		max=str[0];
		for(i=0;i<a;i++)
			if(str[i]>max)
				max=str[i];
		for(i=0;i<a;i++)
			if(str[i]==max)
				break;
		for(j=0;j<=i;j++)
			str0[j]=str[j];
		for(j=i+1;j<a;j++)
			str0[j+3]=str[j];
		str0[i+1]=substr[0];
		str0[i+2]=substr[1];
		str0[i+3]=substr[2];
	    for(i=0;i<a+3;i++)
			printf("%c",str0[i]);
		printf("\n");
	}
}


void main()
{
	int i,j,k,l,n,flag;
	char str[50],substr[4];
	while(scanf("%s%s",str,substr)!=EOF)
	{
		n=strlen(str);
		for(i=0;i<=n-1;i++)
		{
			for(j=0,flag=0;j<=n-1;j++)
				if(str[i]>=str[j])flag++;
			if(flag==n)break;
		}
		for(k=n-1;k>=i+1;k--)
			str[k+3]=str[k];
		for(l=1;l<=3;l++)
			str[i+l]=substr[l-1];
		str[n+3]='\0';
		printf("%s\n",str);}}


int find(char *str,int n)
{
	int max=*str,i,sign;
	for(i=0;i<n;i++)
		if(*(str+i)>max)max=*(str+i),sign=i;
		return sign;
}
void insert(char *a,char *b,int k,int n)
{
	int i,j;
	for(i=n;i>k;i--)
		*(a+i+3)=*(a+i);
	for(j=0;j<3;j++)
		a[++k]=b[j];
}
void main()
{
      char str[100],substr[10];
	  int n,sign;
	  while(scanf("%s%s",str,substr)!=EOF)
	  {
		  n=strlen(str);
	  sign=find(str,n);
	  insert(str,substr,sign,n);
	  printf("%s\n",str);
	  }
}


int main(){
   char str[11]={0},substr[4],str1[10][14]={0}; int i,k,j,m=0;
  while(scanf("%s%s",str,substr)!=EOF)
  {  k=0;
   for(i=1;i<strlen(str);i++)
    if(str[i]>str[k])   k=i;
    for(i=strlen(str)+2;i>k+3;i--)
       str1[m][i]=str[i-3];
    for(i=0;i<=k;i++)
      str1[m][i]=str[i];
          j=0;
    for(i=k+1;i<k+4;i++,j++)
      str1[m][i]=substr[j];
     m++;
      }
   for(i=0;i<m;i++)
   printf("%s\n",str1[i]);
return 0;
}


int main()
{
	char str[11],sub[4],*max,*p;
	while(cin>>str)
	{
		cin>>sub;
		max=str;
		for(p=str;*p;p++)if(*max<*p)max=p;
		for(p=str;p<=max;p++)cout<<*p;
		cout<<sub<<max+1<<endl;
	}
	return 0;
}


void print(int a,int b,char c[])
{int i;
for(i=a;i<=b;i++)
printf("%c",c[i]);
}
int arrange(char a[])
{
	int m=0,i,n;
	n=strlen(a);
	int t=a[0];
		for(i=0;i<n;i++)
		{
			if(a[i]>t)
			{
				m=i;
				t=a[i];
			}
		}
		return m;
}
void main()
{   char a[11],c[4];
	while(scanf("%s%s",a,c)!=EOF)
    {
		int l1=strlen(a),l2=strlen(c);
		int m;
		m=arrange(a);
		print(0,m,a);
		print(0,l2-1,c);
		print(m+1,l1-1,a);
		printf("\n");

	}
}


int main(int argc, char* argv[])
{
	char str[20],substr[20],str2[20];
	while(scanf("%s%s",str,substr)!=EOF){

		int i,j,k,len=strlen(str),max=str[0];
		for(i=0;i<len;i++){
			if(str[i]>max) {
				max=str[i];
				k=i;}}
		for(j=k+1;j<len;j++){
			str2[j-k-1]=str[j];}
		str[k+1]='\0';
		str2[len-k-1]='\0';
		strcat(str,substr);
		strcat(str,str2);
		printf("%s\n",str);

	}
	return 0;
}


int main()
{	int i,j,l,t;
	char str[16],t_max,substr[4];
	while(scanf("%s%s",&str,&substr)!=EOF)
	{
		l=strlen(str);
		t_max=-1;
		for (i=0;i<l;i++)
			if (t_max<str[i])
			{
				t=i;
				t_max=str[i];
			}
		for (i=0;i<=t;i++)
			printf("%c",str[i]);
		printf("%s",substr);
		for (;i<l;i++)
			printf("%c",str[i]);
		printf("\n");
	}
	return 0;
}


int main()
{
	char str[14],cmax,substr[4];
	int i,m,j,n;
	while (scanf("%s %s",str,substr)!=EOF)
	{
		cmax=str[0];m=0;
		for(i=1;;i++)
		{
			if(str[i]=='\0') {n=i;break;}
			else if(str[i]>cmax)
			{
					cmax=str[i];
					m=i;
			}
		}str[n+3]='\0';
		for(i=n+2,j=n-1;;i--,j--)
		{
			str[i]=str[j];
			if(j==m+1) break;
		}
		for(i=m+1,j=0;j<=2;i++,j++)
		{
			str[i]=substr[j];
		}
		printf("%s\n",str);
	}
}


void in(char str[13],char substr[3])
{
	int i,j,k,r;
	for (i=0;i<=9;i++)
	{
		r=1;
		for (j=i;j<=9;j++)
		{
			if(str[i]<str[j])
			{
				r=0;
				break;
			}
		}
		if (r==1)
		{
			for (k=12;k>=i+4;k--)
				{
					str[k]=str[k-3];
				}
				str[i+1]=substr[0];
				str[i+2]=substr[1];
				str[i+3]=substr[2];
				break;
		}
	}
}
void main()
{
	char str[100][13]={0};
	char substr[100][3]={0};
	int i,n;
	char c;
	for(n=0;;n++)
	{
		if((c=getchar())==EOF)
		{
			break;
		}
		else {
			str[n][0]=c;
			scanf("%s %s",&str[n][1],substr[n]);
		}
		in(str[n],substr[n]);

	}
	for (i=0;i<=n-1;i++)
	{

		printf("%s\n",str[i]);
	}
}


int main()
{
	char a[22],b[4],max;
	int i,imax,l1,l2;
	while(scanf("%s%s",a,b)!=EOF)
	{
		l1=strlen(a);
		l2=strlen(b);
		max=a[0];
		imax=0;
		for(i=1;i<l1;i++)
		{
			if(a[i]>max)
			{
				max=a[i];
				imax=i;
			}
		}
		for(i=l1-1;i>imax;i--)
			a[i+l2]=a[i];
		a[l1+l2]='\0';
		for(i=0;i<l2;i++)
			a[imax+i+1]=b[i];
		puts(a);
		printf("\n");
	}
	return 0;
}


char * strInsert(char *str, int n, const char *strIn)
{
	int l = strlen(strIn);
	int i;
	for (i=strlen(str);i>n; i--)
		*(str+i+l)=*(str+i);
	for (i=0;i<l;i++)
		*(str+n+1+i)=*(strIn+i);
	return str;
}
void main()
{
	char str[15], substr[4];
	int i, max;
	short flag;
	do
	{
		flag = scanf("%s %s", str, substr);
		if (flag<2) break;
		max = 0;
		for (i=1; i<strlen(&str[0]); i++)
		{
			if (*(str+i)>*(str+max))
			{
				max = i;
			}
		}
		puts(strInsert(str, max, substr));
	}while (getchar()!=EOF);
}


char maxASCII(char *str)
{
     int len= strlen(str);
     int i,j=0;
     for(i=0; i<len; i++){
              if(str[i]> j) j= str[i];
     }
     return j;
}
int maxlocate(char string[], char maxx)
{
     int x;
     for(x=0; x<strlen(string); x++){
              if(string[x] == maxx){
                           return x;
              }
     }
}

int main(int argc, char *argv[])
{
    char str[100][10], substr[100][4];
    int max;      int rank;
    int i,j;      j=0;
    while(scanf("%s%s",str[j],substr[j])!= EOF) j++;
    for(i=0; i<j; i++){

            max= maxASCII(str[i]);
            rank = maxlocate(str[i], max);
            int a;
            for(a=0; a<=rank; a++){
                     cout << str[i][a];
            }
            cout << substr[i];
            for(a= rank+1; a<strlen(str[i]); a++){
                   cout << str[i][a];
            }
            cout << endl;
    }

    return EXIT_SUCCESS;
}


int max(char s1[11])
{
	int i,k=0;
	char c=0;
	for(i=0;i<strlen(s1);i++)
	{
		if(s1[i]>c) {c=s1[i];k=i;}
	}
	return(k);
}
void main()
{
	char s1[11],s2[4];
	int i,j,m;
	while (scanf("%s%s",s1,s2)!=EOF)
	{
		m=max(s1);
		for(i=0;i<=m;i++) printf("%c",s1[i]);
		printf("%s",s2);
		for(i=m+1;i<strlen(s1);i++) printf("%c",s1[i]);
		printf("\n");
	}
}


int main()
{
	char str[10],substr[10];
	int i,max;
	while(scanf("%s%s",str,substr)!=EOF)
	{
	max=0;
		for(i=0;i<strlen(str);i++)
		{
			if(str[i]>str[max])
			{
				max=i;
			}
		}
		for(i=0;i<=max;i++)
		{
			printf("%c",str[i]);
		}
		for(i=0;i<strlen(substr);i++)
		{
			printf("%c",substr[i]);
		}
		for(i=max+1;i<strlen(str);i++)
		{
			printf("%c",str[i]);
		}printf("\n");
	}
	return 0;
}


int main()
{
	char  str[12],substr[5];
	while(cin>>str>>substr)
	{
	int size=0;
	for(int i=0;i<=10;i++)
	{
		if(str[i]=='\0')
			{size=i;
		break;}
	}
	int tmp=0;
	for(int i=0;i<size;i++)
	{
		if(str[i]>tmp)
		{
			tmp=str[i];
		}
	}
	int j=0;
	for(int i=0;i<size;i++)
	{
		if(str[i]==tmp)
		{
			j=i;break;
		}
	}
	for(int i=0;i<=j;i++)
	{
		cout<<str[i];
	}
	cout<<substr;
	if(j<size-1)
	{
		for(int i=j+1;i<size;i++)
		{
			cout<<str[i];
		}
	}
	cout<<endl;
	}
	return 0;
}


char* findmax (char *p)
{
	char *max;
	for (max=p;*p!='\0';p++)
		if (*p>*max)
			max=p;
	return max;
}

void insert (char *op, char *sp)
{
	char * np;
	np=(char *)malloc(1000);
	char *t = np;
	char *temp;
	char * temp2;
 // printf("%c",*findmax(op));
	for (temp=op;*temp!=*findmax(op);temp++,np++)
		*np= *temp;
	temp2 = temp;
	*np =  *temp;
	np++;

	for (temp=sp;*sp!='\0';np++,sp++)
		*np = *sp;

	for (temp=temp2+1;*temp!='\0';np++,temp++)
		*np= *temp;

	*np='\0';
	while(*t!='\0') {
		printf("%c",*t);
		t++;
	}
  // printf("%c",'\0');
   printf("\n");
}

void main ()
{
	char ori[10], sub[3], newstr[13];
	char * orip = ori, * subp = sub, *newstrp=newstr;
	while (
		scanf ("%s %s", ori, sub)!=EOF)
	{

	 insert(orip,subp);
	//	printf ("%s\n", newstrp);
	}
}


int main()
{

    char a[20],b[4];
    while (cin>>a>>b)
    {
          char *pa,*pb=b,*pmax=a;
          for (pa=a; pa!=&a[strlen(a)]; pa++)
              if (*pa>*pmax) pmax=pa;   //??ASCII????????pmax??????
          for (pa=&a[strlen(a)]; pa!=pmax; pa--)  //?pmax??????????? ?b????
              *(pa+3)=*pa;
          for (pa=pmax+1,pb=b;pb!=&b[3];pa++,pb++)  //?b???pmax???????
              *pa=*pb;
          pa=a;
          cout<<pa<<endl;
    }

return 0;
}


void main()
{
    char str[20]={0},substr[4]={0},max=0,medium[20]={0};
	int i,j,length,mark;
	while(scanf("%s%s",str,substr)==2)
	{
        max=0;length=strlen(str);
		for(i=0;i<length;i++)
		{
			if(max<str[i])
			{max=str[i];mark=i;}
		}
        for(j=0,i=mark+1;i<length;i++,j++)
		{
			medium[j]=str[i];str[i]=0;
		}
        strcat(str,substr);
		strcat(str,medium);
		printf("%s\n",str);
		for(i=0;i<10;i++)
		{
			medium[i]=0;str[i]=0;
		}
	}

}


void main()
{
	int k=0,i,len;
	char str[11],substr[4];
	while (scanf("%s%s",str,substr)!=EOF)
	{
		k=0;
	len=strlen(str);
	for(i=1;i<len;i++)
		if(str[i]>str[k])
			k=i;
	for(i=0;i<=k;i++)
			printf("%c",str[i]);
	printf("%s",substr);
	for(i=k+1;i<len;i++)
			printf("%c",str[i]);
         printf("\n");
	}
}


void main()
{
	char str[11],substr[3],*p,*max;

	while(scanf("%s %s",str,substr)!=EOF){
	for(p=str,max=p;*p!='\0';p++)
	{
		if(*p>*max)
			max=p;
	}
	for(p=str;p<=max;p++)
		printf("%c",*p);
	printf("%s",substr);
	for(p=max+1;*p!='\0';p++)
		printf("%c",*p);
	printf("\n");}
}


int main()
{
	char str[11],substr[4],temp;
	int p,i;
	while(cin)
	{
		p=0;
		for(i=0;i<11;i++)
			str[i]='\0';
		for(i=0;i<4;i++)
			substr[i]='\0';
		cin.getline(str,11,' ');
		cin.getline(substr,4,'\n');
		temp=str[0];
		for(i=0;str[i]!='\0';i++)
			if(str[i]>temp)
			{
				temp=str[i];
			    p=i;
			}
		for(i=0;i<=p;i++)
			cout<<str[i];
		cout<<substr;
		for(i=p+1;str[i]!='\0';i++)
			cout<<str[i];
		cout<<endl;
	}
		return 0;
}


void main()
{ char str[100][10],substr[100][3];
  int m,k,n=0,i,j;char max;

  while(scanf("%s %s",str[n],substr[n])!=EOF)
     {
         n++;
     }
  for(i=0;i<n;i++)
      {
          m=strlen(str[i]);
         j=0; max=str[i][j];
         for(j=1;j<m;j++)
           {
               if(str[i][j]>max)  {max=str[i][j];k=j;}
           }

        for(j=0;j<=k;j++)
            {printf("%c",str[i][j]);}
        for(j=0;j<3;j++)
           {
               printf("%c",substr[i][j]);
           }
        for(j=k+1;j<m;j++)
          {
              printf("%c",str[i][j]);
          }
          printf("\n");
      }
}


void main()
{
	int i,n,j;
	char str[10],substr[3];
	int f(char str[10]);
	for(j=0;scanf("%s %s",str,substr)!=EOF;j++)
	{
	n=strlen(str);
	for(i=0;i<=f(str);i++)
		printf("%c",str[i]);
	printf("%s",substr);
	for(i=f(str)+1;i<n;i++)
		printf("%c",str[i]);
	printf("\n");
	}
}
int f(char str[10])
{
	char c;
	int n,i,x=0;
	c=str[0];
	n=strlen(str);
	for(i=1;i<n;i++)
	{
		if(str[i]>c)
		{
			c=str[i];
			x=i;
		}
	}
	return(x);
}


int main()
{
    int i,ii;
    char res[100][20];
    int p=0;
    char c,sub1[20],sub2[20];
    char str[20],substr[5];
while(scanf("%s %s", str,substr)!=EOF)
{
                c=0;
      for(i=0;i<strlen(str);i++)
     if(str[i]>c) {c=str[i]; ii=i;}
          strcpy(sub1,str);
     sub1[ii+1]='\0';
     strcpy(sub1,strcat(sub1,substr));
     for(i=ii+1;i<strlen(str);i++)
     sub2[i-ii-1]=str[i];
     sub2[strlen(str)-ii-1]='\0';
     strcpy(res[p],strcat(sub1,sub2));
                p++;
}
for(i=0;i<p;i++)
printf("%s\n",res[i]);
}


int max(char a[])
{
	int i,t=a[0];
	for(i=0;i<=strlen(a);i++)
	{
		if(t<a[i])
			t=a[i];
	}
	i=0;
	while(a[i]!=t)
		i++;
	return i;
}
void main()
{
char str[11],substr[4];
while(scanf("%s%s",str,substr)!=EOF)
{
	int i;
	int t=max(str);
	for(i=0;i<=t;i++)
		printf("%c",str[i]);
	printf("%s",substr);
	for(i=t+1;i<strlen(str);i++)
		printf("%c",str[i]);
	printf("\n");
}
}


void main()
{
	int p,q,m,n,i;
	char str[15],substr[5];

	while(scanf("%s",str)!=EOF)
	{
		scanf("%s",substr);
		p=strlen(str);
		q=0;
		for(i=1;i<p;i++)
		{
			if( (m=str[i]) >(n=str[q]) )
				q=i;

		}
		for(i=0;i<=q;i++)
		{printf("%c",str[i]);}
		printf("%s",substr);
		for(i=q+1;i<p;i++)
		{printf("%c",str[i]);}
		printf("\n");
	}
}


void main()
{
	int n,i,m,c,f;

	char str[20],substr[10],de[20],max;
	char *p,*q,*t;
	while (scanf("%s%s",str,substr)!=EOF)
	{
		n=strlen(str);
		m=strlen(substr);
		max=0;
		for(p=str;p<(str+n);p++)
		   if(*p>max)
		   {
		   max=*p;
		   t=p;
		   }
		//t=&max;
		for(p=str,i=0;p<(t+1);p++)
		  de[i++]=*p;
		for(c=i,q=substr;q<(substr+m);q++)
		  de[c++]=*q;
		for(p=(t+1),f=c;p<(str+n);p++)
		  de[f++]=*p;
		for(q=de;q<(f+de);q++)
		printf("%c",*q);
		printf("\n");
	}
}


int posi(char str[])
{
    int i,k=0;
    for(i=1;i<strlen(str);i++)
    {
                              if(str[i]>str[k])k=i;
    }
    return k+1;
}
int main()
{
    char str[20],substr[4];
    while(scanf("%s%s",str,substr)!=EOF)
    {
                                        int k,i,j,l=strlen(str);
                                        k=posi(str);
                                        for(i=l;i>=k;i--)
                                        {
                                                         str[i+3]=str[i];
                                        }
                                        for(i=0;i<3;i++)
                                        {
                                                        str[k+i]=substr[i];
                                        }
    printf("%s\n",str);
    }
}


void main()
{
	int n,i,j,Asc,point;
	char str[10],substr[3];
	while (scanf("%s%s",str,substr)==2)
	{
		point=0;Asc=0;
		for (i=0;i<=strlen(str);i++)
			if (str[i]>Asc)
			{
				Asc=str[i];
				point=i;
			}
		for (i=0;i<=point;i++)
			printf("%c",str[i]);
		for ( j=0;j<strlen(substr);j++)
			printf("%c",substr[j]);
		for (i=point+1;i<strlen(str);i++)
			printf("%c",str[i]);
                   printf("\n");
	}
}


void main()
{
	void insert(char a[],char b[]);
	char a[10],b[3];
	while ( (scanf("%s %s",a,b)) != EOF )
		insert(a,b);
}
void insert(char a[],char b[])
{
	int i,j,len,max;
	len=strlen(a);
	max=a[0];
	for(i=1;i<len;i++)
	{
		if(max<a[i])
		{
			max=a[i];
			j=i;
		}
	}
	for(i=0;i<=j;i++)
		printf("%c",a[i]);
	for(i=0;i<3;i++)
		printf("%c",b[i]);
	for(i=j+1;i<len;i++)
	    printf("%c",a[i]);
		printf("\n");
}


void main()
{
	int i=0,j,k,n,x,y,z=0;
	char str[100][12],substr[100][5];
    while(scanf("%s%s",&str[i],&substr[i])!=EOF)
	{
		n=strlen(str[i]);
		for(j=0;j<n;j++)
		{
			z=0;
			for(k=0;k<n;k++)
			{
				if(str[i][j]>=str[i][k])z++;
			}
				if(z==n)break;

		}
	    for(y=0;y<=j;y++)printf("%c",str[i][y]);
	    printf("%s",substr[i]);
		for(y=j+1;y<n;y++)printf("%c",str[i][y]);
	    printf("\n");

		i++;
	}

}


void main()
{
 char str[15],substr[3];
 int b,i,j;
 while (scanf("%s %s",str,substr)!=EOF)
 {
 b=strlen(str);j=0;
 str[b]=97;substr[3]=97;
 for (i=1;i<=b-1;i++)
   if (str[i]>str[j])
     j=i;
 for (i=b-1;i>=j+1;i--)
   str[i+3]=str[i];
 for (i=j+1;i<=j+3;i++)
   str[i]=substr[i-1-j];
 str[b+3]='\0';
 printf("%s\n",str);
 }
}


int main()
{
   int len,i,j,maxASCII=0,max;
   char str[15],substr[4],*p=str,*q=substr;
   while(cin>>str>>substr)
   {
      maxASCII=0;
      len=strlen(str);
      for(i=0;i<len;i++)
      {
          if(*(p+i)>maxASCII)
          {
             maxASCII=*(p+i);
             max=i;
          }
      }
      for(i=len-1;i>max;i--)
      {
          *(p+i+3)=*(p+i);
      }
      for(i=max+1,j=0;i<=max+3;i++,j++)
      {
          *(p+i)=*(q+j);
      }
      for(i=0;i<len+3;i++)
      {
          cout<<str[i];
      }
      cout<<endl;
   }
   return 0;
}


int MaxIndex(char * str)
{
	char maxChar = 0;
	int i = 0,j = 0;
	while(*str!=0)
	{
		if(maxChar < *str)
		{
			maxChar = *str;
			i = j;
		}
		j++;
		str++;
	}
	return i;
}
void fun(char * str, char * substr)
{
	int max = MaxIndex(str);
	str += max;
	char * temp = str;
	while(*(temp++) != 0);
	*(temp+3) = 0;
	while((--temp) != str)
	{
		*(temp+3) = *temp;
	}
	while(*substr != 0)
	{
		*(++temp) = *substr++;
	}
}
int main()
{
	char str[16], substr[4];
	int i, lenth;
	int maxAsc = 0;
	char maxChar = 0;
	while(scanf("%s%s",str,substr) == 2)
	{
		fun(str,substr);
		printf("%s\n",str);
	}
}


void main()
{
	int i,j,m,n;
	char str[11],substr[4],s[15];
	while(scanf("%s %s",str,substr)!=EOF)
	{
		m=strlen(str);
		n=strlen(substr);
		j=0;
		for(i=0;i<m;i++)
		{
			if(str[i]>str[j]) j=i;
		}
		for(i=0;i<=j;i++) s[i]=str[i];
		for(i=j+1;i<j+1+n;i++) s[i]=substr[i-j-1];
		for(i=j+1+n;i<m+n;i++) s[i]=str[i-n];
		s[m+n]='\0';
		printf("%s\n",s);
	}
}


void main()
{int i,j,len,max=0;
char str[13],substr[3],t[13]={'\0'},c;

scanf("%s",str);
len=strlen(str);
scanf("%s",substr);
c=getchar();
//scanf("%s\n",substr);

while(c=='\n')
{
	/*for(i=len;i>0;i--)
	str[i]=str[i-1];
	str[0]=c;
	len++;*/
for(i=0;i<len;i++)
	if(str[i]>max) max=str[i];
for(i=0;str[i]!=max;i++);
	for(j=i+1;j<len;j++)
		t[j-i-1]=str[j];
	str[i+1]='\0';
	strcat(str,substr);
	strcat(str,t);
	puts(str);
for(i=0;i<len;i++)
	t[i]='\0';//puts("t=");puts(t);
	max=0;

scanf("%s",str);
len=strlen(str);
scanf("%s",substr);
c=getchar();

}
}


int main()
{
	char str[11],substr[4],max;
	int i,k,l;
	while(scanf("%s %s",str,substr)!=EOF)
	{
		k=0;
		l=strlen(str);
		max=str[0];
		for(i=1;i<l;i++)
		{
			if(str[i]>max)
			{
				max=str[i];
				k=i;
			}
		}
		for(i=0;i<l;i++)
		{
			if(i==k)
			{
				printf("%c",str[i]);
				printf("%s",substr);
			}
			else
			{
				printf("%c",str[i]);
			}
		}
		printf("\n");
	}
	return 0;
}


void main()
{
	char str[15],substr[3];
	int n,i,j;
	while (scanf("%s %s",str,substr)!=EOF)
	{
		n=strlen(str);
		j=0;
		str[n]=97;
		substr[3]=97;
		for(i=1;i<=n-1;i++)
		{
			if(str[i]>str[j])
				j=i;
		}
		for(i=n;i>=j+1;i--)
		{
			str[i+3]=str[i];
		}
		for(i=j+1;i<=j+3;i++)
		{
			str[i]=substr[i-1-j];
		}
		str[n+3]='\0';
		printf("%s\n",str);
	}
}


main()
{
	char str[20],substr[4],str1[15]={0};
	int i,j,k,e,b;
	while((scanf("%s%s",str,substr))!=EOF)
	{
		b=strlen(str);
		for(j=0;j<b;j++)
		{
			e=0;
			for(k=0;k<b;k++)
			{
				if(str[k]>str[j]) e=1;
			}
			if(e==0) break;
		}
		for(k=0;k<=j;k++)
		{
			str1[k]=str[k];
		}
		for(k=0;k<3;k++)
		{
			str1[j+k+1]=substr[k];
		}
		for(k=j+1;k<b;k++)
		{
			str1[k+3]=str[k];
		}
		str1[b+3]=0;
		strcpy(str,str1);
		puts(str);
	}
	return 0;
}


void main()
{
	long j;
	int i,N,a[301]={0};
	int sum,max,min;
	scanf("%d",&N);
	scanf("%d",&a[0]);
	sum=max=min=a[0];
	for(i=1;i<N;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
		if(a[i]>max)max=a[i];
		else if(a[i]<min)min=a[i];
	}
	j=(max*N-sum)-(sum-min*N);

	if(j>0)printf("%d",max);
	else if(j==0)printf("%d,%d",min,max);
	else printf("%d",min);
}


int main()
{
	double shu[300];
	double ping;
	int n;
	cin>>n;
	for (int i=0;i<n;i++)
		cin>>shu[i];
	double sum=0;
	for (int i=0;i<n;i++)
		sum=sum+shu[i];
	ping=sum/n;
	double temp;
	for (int i=0;i<n-1;i++)
	{
		for (int j=i+1;j<n;j++)
		{
			if (shu[i]>shu[j])
			{
				temp=shu[i];
				shu[i]=shu[j];
				shu[j]=temp;
			}
		}
	}
	double cha[300];
	for (int i=0;i<n;i++)
		cha[i]=abs(ping-shu[i]);
	double max=0;
	for (int i=0;i<n;i++)
	{
		if (max<=cha[i]) max=cha[i];
	}
	int count=0;
	int flag;
	for (int i=0;i<n;i++)
	{
		if (max==cha[i]) {count++;flag=i;}
	}
	if (count==1) cout<<shu[flag];
	else
	{
		for (int i=0;i<n;i++)
		{
			if (max==cha[i]) {cout<<shu[i];flag=i;break;}
		}
		for (int i=flag+1;i<n;i++)
		{
			if (max==cha[i]) cout<<','<<shu[i];
		}
	}
	return 0;
}


int main(int argc, char* argv[])
{
	int n,i,a[300],s=0;
	double t,max=0;
	int x,y,flag;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		s+=a[i];
	}
	t=(float)s/n;
	for(i=0;i<n;i++)
	{
		if(fabs(a[i]-t)>max)
		{
			x=a[i];
			max=fabs(a[i]-t);
			flag=0;
		}
		else if(fabs(a[i]-t)==max)
		{
			y=a[i];
			flag=1;
		}
	}
	if(flag){
		if(x>y){
			printf("%d,%d",y,x);
		}
		else{
			printf("%d,%d",x,y);
		}
	}
	else{
		printf("%d",x);
	}
	return 0;

}


int main()
{
	int n,sum=0,i,j,a[301],temp;
	double ave;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",(a+i));
	for(i=0;i<n;i++)
		sum+=*(a+i);
	ave=(double)sum/(double)n;
	for(j=1;j<n;j++)
	{
		for(i=0;i<n-j;i++)
		{
			if(fabs(ave-*(a+i))<fabs(ave-*(a+i+1)))
			{
				temp=*(a+i);
				*(a+i)=*(a+i+1);
				*(a+i+1)=temp;
			}
		}
	}
	temp=0;
	for(i=0;i<n;i++)
	{
		if(fabs(ave-*(a+i))!=fabs(ave-*(a+i+1)))
		{
			if(temp==0)
			{
				printf("%d",*(a+i));
				temp++;
			}
			else
				printf(",%d",*(a+i));
			break;
		}
		else
		{
			if(temp==0)
			{
				printf("%d",*(a+i));
				temp++;
			}
			else
				printf(",%d",*(a+i));
		}
	}
	printf("\n");
	return 0;
}


int main()
{
    int num[300];
    float average=0,temp,max=0;
    int i,n,flag=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",num+i);

    for(i=0;i<n;i++)
        average+=num[i];
    average/=n;

    for(i=0;i<n;i++)
        {
         temp=fabs(average-num[i]);
         if(temp>max)
            max=temp;
         }
    for(i=0;i<n;i++)
        {
         if(fabs(fabs(num[i]-average)-max)<=0.001)
            {
             if(flag==0)
                flag=1;
             else
                 printf(",");
             printf("%d",num[i]);
            }
        }
    return 1;
}


void main()
{
  long i,s,k,n,max,min;
  scanf("%ld\n",&n);
  min=32767; max=0; s=0;
  for (k=1;k<=n;k++){scanf("%ld",&i); if(max<i)max=i; if(min>i)min=i; s+=i;}
  if ((max*n-s)>(s-min*n)) printf("%ld\n",max);
  else if ((max*n-s)<(s-min*n)) printf("%ld\n",min);
  else printf("%ld,%ld",min,max);
}


void bubble(int *p,int n)
{
	int i=0,pass,temp;

	for(pass=1;pass<=n;pass++)
	{
		for(i=0;i<n-pass;i++)
		{
			if(*(p)>*(p+1))
			{
				temp=*(p);
				*(p)=*(p+1);
				*(p+1)=temp;
			}
		}
	}
	return;
}
float ffabs(float x)
{
	if(x>0)
		return x;
	else
		return -x;
}
void main()
{
	int n,i,*num,sum=0,*temp,r=0;
	float ave,max=0.0;

	scanf("%d",&n);

	num=(int *)malloc(n*sizeof(int));
	temp=(int *)malloc(n*sizeof(int));
	for(i=0;i<n;i++)
	{
		scanf("%d",(num+i));
		sum+=*(num+i);
	}

	ave=(float)sum/(float)n;

	for(i=0;i<n;i++)
	{
		if(ffabs((float)*(num+i)-ave)>=max)
			max=ffabs((float)*(num+i)-ave);
	}

	for(i=0;i<n;i++)
	{
		if(ffabs(ffabs((float)*(num+i)-ave)-max)<0.0000001)
		{
			*(temp+r)=*(num+i);
			r++;
		}
	}
	if(r==1)
	{
		printf("%d",*(temp+0));
	}
	else
	{
		bubble(temp,r);
		for(i=0;i<r;i++)
		{
			printf("%d%c",*(temp+i),(i!=r-1?',':'\n'));
		}
	}
}


float my_abs(float a)
{
	return a < 0 ? -a : a;
}

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

	int n;
	scanf("%d", &n);

	float avg = 0;
	float data[400];
	for (int i = 0;i < n; i++)
	{
		scanf("%f", &data[i]);
		avg += data[i];
	}
	avg /= n;

	float dif[400];
	for (int i = 0;i < n; i++)
	{
		dif[i] = my_abs(data[i] - avg);
	}

	float maxDif = dif[0];
	float maxIdx = 0;
	for (int i = 1;i < n; i++)
	{
		if (maxDif < dif[i])
		{
			maxDif = dif[i];
			maxIdx = i;
		}
	}

	int result[400];
	int sp = 0;
	for (int i = 0; i < n; i++)
	{
		if (dif[i] == maxDif)
		{
			result[sp++] = data[i];
		}
	}

	if (sp == 2)
	{
		if (result[0] > result[1])
		{
			int temp = result[0];
			result[0] = result[1];
			result[1] = temp;
		}
	}

	for (int i = 0; i < sp; i++)
	{
		printf("%d%c", result[i], i==sp-1 ? '\n' : ',');
	}

	return 0;
}


int main(int argc, char* argv[])
{
	int i,n,num[300],s,j,b,c;
	double ave,v[300],a;
	s=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&num[i]);
		s+=num[i];
	}
	ave=(double)s/n;
	for(i=0;i<n;i++){
		if(num[i]<ave){
			v[i]=ave-num[i];
		}
		else{
			v[i]=num[i]-ave;
		}
	}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(v[j]>v[i]){
				a=v[j];
				v[j]=v[i];
				v[i]=a;
				b=num[j];
				num[j]=num[i];
				num[i]=b;
			}
		}
	}
	if(v[i]==v[i+1]&&num[i]>num[i+1]){
			c=num[i];
			num[i]=num[j];
			num[j]=c;
		}
	printf("%d",num[0]);
	for(i=0;i<n-1;i++){
		if(v[i]==v[i+1]&&num[i]>num[i+1]){
			c=num[i];
			num[i]=num[j];
			num[j]=c;
		}
		else if(v[i]>v[i+1]){
			break;
		}

		printf(",%d",num[i+1]);

	}
	printf("\n");

	return 0;
}


int main() {
	struct data1 {
		int num;
		float min;
	} data[1000], temp;
	int n, i,j;
	float sum=0, max;
	scanf("%d", &n);
	for(i=0;i<n;i++) {
		scanf("%d", &data[i].num);
		sum+=data[i].num;
	}
	sum=sum/n;
	for(i=0;i<n;i++) {
		if(data[i].num>=sum) {
			data[i].min=data[i].num-sum;
		} else {
			data[i].min=sum-data[i].num;
		}
	}
	for(i=0;i<n;i++) {
		for(j=n-1;j>0;j--) {
			if(data[j].min>data[j-1].min) {
				temp=data[j];
				data[j]=data[j-1];
				data[j-1]=temp;

			}
		}
	}
	max=data[0].min;
	printf("%d", data[0].num);
	for(i=1;fabs(data[i].min-max)<1e-6;i++) {
		printf(",%d", data[i].num);
	}
	return 0;
}


int main()
{
	int i,j,k,l,m,n;
	double average,sum=0.0,max;
	int a[305];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	average=sum/n;
	max=fabs(a[0]-average);
   // printf("%lf  %lf",average,max);
	for(i=1;i<n;i++)
	{
		if(fabs(a[i]-average)>max) max=fabs(a[i]-average);
	}
    for(i=0;i<n;i++)
	{
		if(max-fabs(a[i]-average)<1e-6) {printf("%d",a[i]);
		break;}
	}
	for(i++;i<n;i++)
	{

		if(max-fabs(a[i]-average)<(1e-6)) printf(",%d",a[i]);
	}
	return 0;
}


int main()
{
	unsigned int i,n,a[M],flag=1;
	double ave=0,max=0;

	scanf("%u",&n);
	for (i=0;i<n;i++)
	{
		scanf("%u",&a[i]);
		ave+=a[i];
	}
	ave=ave/n;

	for (i=0;i<n;i++)
	{
		double c;

		if ((c=fabs(ave-a[i])-max)>0 && fabs(c)>E) max+=c;
	}

	for (i=0;i<n;i++)
		if (fabs(fabs(a[i]-ave)-max)<E)
		{
			if (!flag) printf(",");
			printf("%u",a[i]);
			if (flag) flag=0;
		}

	return 0;
}


int main(){
	int a[300],n,i,j,he=0,temp,num=0;
	float pingjun,max;
	cin>>n;
	for(i=0;i<=n-1;i++)
	{
		cin>>a[i];
		he+=a[i];
	}
	pingjun=(float)he/(float)n;
	for(i=n-1;i>=1;i--)
		for(j=0;j<=i-1;j++)
		{
			if(a[j]>a[j+1])
			{
				temp=a[j+1];
				a[j+1]=a[j];
				a[j]=temp;
			}
		}
	for(i=0;i<=n-1;i++)
		if(abs(a[i]-pingjun)>max)
			max=abs(a[i]-pingjun);
	for(i=0;i<=n-1;i++)
		if(abs(abs(a[i]-pingjun)-max)<0.1)
		{
			num++;
			if(num==1)
				cout<<a[i];
			if(num>1)
				cout<<","<<a[i];
		}
	return 0;

}


float f(float a)
{
	if(a<0)
	return -a;
	else
	return a;
}
int main()
{
	float n;
	cin>>n;
    double a[100];
	int i,j;
	float sum=0;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		sum=sum+a[i];
	}
	float ave,t;
	ave=sum/n;

	for(i=1;i<=n;i++)
	  {
	  	for(j=1;j<=n-i;j++)
	  	{
	  		if(a[j+1]<a[j])
	  		{
	  		  t=a[j];a[j]=a[j+1];a[j+1]=t;
	  		}
	  	}
	  }
	float max=f(a[1]-ave);
	for(i=2;i<=n;i++)
	{

		if(f(a[i]-ave)>max)
		max=f(a[i]-ave);
	}
	float z=0;
	for(i=1;i<=n;i++)
	{

		if((f(a[i]-ave)==max)&&(z==0))
		{
		 cout<<a[i];
		 z=1;
		 continue;
	    }
	    if((f(a[i]-ave)==max)&&(z==1))
		{
		 cout<<",";
		 cout<<a[i];
		 z=1;
	    }

	}
	return 0;

}


int main()
{
	int n,min=1000, max=0;
	float average=0.0, sum=0;
	cin>>n;
	int array[N];
	for(int i=0; i<n; i++)
	{
		cin>>array[i];
		sum+=array[i];
		if(array[i]>max) max=array[i];
		if(array[i]<min) min=array[i];
	}
	average=sum/n;
	float cha=0;

	if(fabs(max-average)>fabs(min-average))
	cout<<max<<endl;
	else if(fabs(max-average)<fabs(min-average))
	cout<<min<<endl;
	else
	cout<<min<<","<<max<<endl;

	return 0;
}


int main()
{
    double Numbers[500]={0};
    double Temp[100]={-1};
    double Ave=0;
    double Sum=0;
    double Max=0;
    double Exchange=0;
    int k=0;
	int n=0;
	int i=0;
    int j=0;
	cin>>n;
	for (i=0;i<n;i++)
    {cin>>Numbers[i];
     Sum+=Numbers[i];}
    Ave=Sum/n;
    for (i=0;i<n;i++)
    { if (fabs(Numbers[i]-Ave)>Max)
       {Max=fabs(Numbers[i]-Ave);}
    }
   for (i=0;i<n;i++)
   {if (fabs(fabs(Numbers[i]-Ave)-Max)<1e-5)
     {Temp[k]=Numbers[i];
      k++;
     }
   }
  if (k==1)
    {cout<<Temp[0]<<endl;}
  else
    { for (i=0;i<k-1;i++)
       {  for (j=0;j<k-1;j++)
           { if (Temp[j]>Temp[j+1])
                  {  Exchange=Temp[j];
                     Temp[j]=Temp[j+1];
                     Temp[j+1]=Exchange;
                  }
           }
       }
     cout<<Temp[0];
     for (i=1;i<k;i++)
     {cout<<","<<Temp[i];}
     cout<<endl;
    }

return 0;
}


int main()
{
	int n,a[500],min=100000,max=0,sum=0;
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++)
	{
		if(a[i]>max) max=a[i];
		if(a[i]<min) min=a[i];
		sum+=a[i];
	}
	if(sum-min*n<max*n-sum) cout<<max;
	else if(sum-min*n>max*n-sum) cout<<min;
	else cout<<min<<','<<max;
	return 0;
}


struct prin
{
	double b;
	int a,flag;
};
int main()
{
	double n,ar=0;
	struct prin p[10000];
	int i,j;
	double k;
	scanf("%lf",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&p[i].a);
	}
	for(i=0;i<n;i++)
	{
		ar=ar+p[i].a/n;
	}
	for(i=0;i<n;i++)
	{
		p[i].b=(double)fabs(p[i].a-ar);
		p[i].flag=0;
	}
	k=p[0].b;
	for(i=0;i<n;i++)
	{
		if(p[i].b>k)
			k=p[i].b;
	}
	for(i=0;i<n;i++)
	{
		if(p[i].b==k)
		{
			p[i].flag=1;
		}
	}
	for(i=0;i<n;i++)
	{
		if(p[i].flag==1){
			printf("%d",p[i].a);
			break;
		}
	}
	for(j=i+1;j<n;j++)
	{
		if(p[j].flag==1)
			printf(",%d",p[j].a);
	}
	return 0;
}


int main()
{
	int n;
	int i,j;
	int a[300];
	float b[300];
	int c[300];
	int t=0;
	int sum=0;
	int temp;
	float ave;
	float max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	ave=(float)sum/n;
	for(i=0;i<n;i++)
	{
		if(a[i]-ave>=0)
			b[i]=a[i]-ave;
		else
			b[i]=ave-a[i];
		if (b[i]>max)
			max=b[i];
	}
	for(i=0;i<n;i++)
	{
		if(b[i]==max)
		{
			c[t]=a[i];
			t++;
		}
	}
	for(i=1;i<t;i++)
	{
		for(j=0;j<t-i;j++)
		{
			if(c[j]>c[j+1])
			{
				temp=c[j];
				c[j]=c[j+1];
				c[j+1]=temp;
			}
		}
	}
	for(i=0;i<t-1;i++)
		printf("%d,",c[i]);
	printf("%d",c[t-1]);
	return 0;
}


void main()
{
	int a[300],n,i,j,temper;
	float average,sum=0,b[300];
    scanf("%d",&n);
	for(i=0;i<n;i++)
	{
	scanf("%d",&a[i]);
	sum=sum+a[i];
	}
	average=sum/n;
    //printf("%f",average);
	for(i=0;i<n;i++)
	{
		if(a[i]>average)
		b[i]=a[i]-average;
		else
		b[i]=average-a[i];
	}
	//for(i=0;i<n;i++)
	//{
		//printf("%d",b[i]);
	//}
	for(i=0;i<n-1;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(b[i]<b[j])
			{temper=a[i];
			a[i]=a[j];
			a[j]=temper;
			temper=b[i];
			b[i]=b[j];
			b[j]=temper;}

		}

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

}


int main()
{
	int n;
	double sum = 0.0;
	double ave;
	double a[300];
	double b[300];
	double c[300] = {0.0};
	int d[300];
	int i, j, num = 0;
	double temp;
	cin >> n;
	for ( i = 0; i < n; i++ )
	{
		cin >> a[i];
		sum = sum + a[i];
	}
	for ( i = 0; i < n - 1; i++ )
		for ( j = 0; j < n - 1 - i; j++ )
			if ( a[i] < a[j] )
			{
				temp = a[i];
				a[i] = a[j];
				a[j] = temp;
			}
	ave = sum / n;
	for( i = 0; i < n; i++ )
	{
		b[i] = fabs(a[i] - ave);
	}
	double max = 0.0;
	for( i = 0; i < n; i++ )
		if ( b[i] > max )
			max = b[i];
	for( i = 0; i < n; i++ )
		if ( (max - b[i]) < 1e-6 )
			num++;
	if ( num == 1 )
	{
		for ( i = 0; i < n; i++ )
			 if ( (max - b[i]) < 1e-6 )
			cout << a[i] << endl;
			 }
	if ( num > 1 )
	{
		for ( i = 0; i < n; i++ )
		{
			if ( (max - b[i]) < 1e-6 )
			{
				if ( num == 1 )
				cout << a[i];
				if ( num > 1 )
				{
					cout << a[i] << ",";
					num--;
				}
			}
		}
	}

	return 0;
}


double num[400];
double dis[400];

int main()
{
    int n;
    int i,j;
    double temp;
    double ave=0;
    const double min=1e-6;
    double max=0;

    cin>>n;
    for(i=0;i<n;i++)
        {
         cin>>num[i];
         ave+=num[i];
         }
    ave=ave/n;
    for(i=n-2;i>=0;i--)
        for(j=0;j<=i;j++)
            if(num[j]>num[j+1])
               {
                temp=num[j];
                num[j]=num[j+1];
                num[j+1]=temp;
               }

    for(i=0;i<n;i++)
        dis[i]=fabs(num[i]-ave);
    for(i=0;i<n;i++)
        if(max<dis[i])max=dis[i];
    for(j=n-1;j>=0;j--)
        if(fabs(max-dis[j])<min) break;
    for(i=0;i<j;i++)
        {if(fabs(max-dis[i])<min)cout<<num[i]<<",";}
    cout<<num[j];

    return 0;
}


//#include<string.h>
int i,n,a[1000],max,min;
float aver;

int main(){

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

    if(max+min-aver*2==0)  printf("%d,%d\n",min,max);
    if(max+min-aver*2<0)  printf("%d\n",min);
    if(max+min-aver*2>0)  printf("%d\n",max);

scanf("%d",&i);
return 0;
}


int main()
{
	int n, i, j, a[10000];
	float sum=0, ave, max=0, b, c, d, e;
	scanf("%d", &n);
	for(i=0; i<n; i++)
	{
		scanf("%d", &a[i]);
		sum=sum+(float)a[i];
	}
	ave=sum/(float)n;
	c=ave;
	b=ave;
	for(j=0; j<n; j++)
	{
		if((float)a[j]>c)
			c=(float)a[j];
		else if((float)a[j]<b)
			b=(float)a[j];
	}
	d=c-ave;
	e=ave-b;
	if(d>e)
	    printf("%d\n", (int)c);
	else if(d<e)
		printf("%d\n", (int)b);
	else
		printf("%d,%d\n", (int)b, (int)c);
	return 0;
}


int n,sum=0,a[100],b[100];
double ave,max=0;
void bubble(int *a,int n)
{
	int i,j,m;
	for (i=1;i<n;i++)
		for (j=0;j<n-i;j++)
			if(a[j]>a[j+1])
			{
				m=a[j];
				a[j]=a[j+1];
				a[j+1]=m;
			}

}
void fuc()
{
	int i,j=0;
	ave=(double)sum/n;
	for (i=0;i<n;i++)
	{
		max=(fabs(ave-a[i])>max) ? 	fabs(ave-a[i]) : max;
	}
	for (i=0;i<n;i++)
	{
		if (fabs(fabs(ave-a[i])-max)<1e-6) b[j++]=a[i];
	}
	bubble(b,j);
	for (i=0;i<j;i++)
	{
		printf("%d%c",b[i],(i==j-1)?'\n':',');
	}
}
void main()
{
	int i;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%d",a+i);
		sum+=a[i];
	}
	fuc();
}


void main()
{
	float a[300];
	unsigned int b[300],i,j=0,n;
	float sum=0,p,max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%f",&a[i]);
		sum+=a[i];
	}
	p=(float)sum/n;
	for(i=0;i<n;i++)
	if(fabs(a[i]-p)>max)
			max=fabs(a[i]-p);
	for(i=0;i<n;i++)
		if(fabs(fabs(a[i]-p)-max)<0.01)
			b[j++]=(int)a[i];
	if(j==1)
		printf("%d\n",b[0]);
	else
		for(i=0;i<j;i++)
			printf("%d%c",b[i],i<j-1?',':'\n');
}


int main()
{
int n;
double in[400];
double cha[400]={0};
int i,j,k,s=0;
double temp=0;
int flag[400]={0};
double to=0,aver;
cin>>n;
for(i=0;i<=n-1;i++){
	cin>>in[i];
	to=to+in[i];
}
aver=to/n;
//cout<<aver<<endl;
for(i=0;i<=n-1;i++){
	cha[i]=fabs(in[i]-aver);
//	cout<<cha[i]<<endl;
}
for(i=0;i<=n-1;i++){
	if(temp<cha[i]){
		temp=cha[i];
	}
}
//cout<<temp;
for(i=0;i<=n-1;i++){
	if(fabs(cha[i]-temp)<=0.00000001){
		flag[s]=i;
		s++;
	}
}
for(i=0;i<=s-2;i++){
	cout<<in[flag[i]]<<",";
}
cout<<in[flag[s-1]]<<endl;
return 0;
}


int main ()
{
	float a[300];
	int n,i,j,k;
	float average,c;
	float sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%f",&a[i]);
		sum=sum+a[i];
	}
	for(j=0;j<n-1;j++)
	{
		for(k=0;k<n-1-j;k++)
		{
			if(a[k]>a[k+1])
			{
				c=a[k];
				a[k]=a[k+1];
				a[k+1]=c;
			}
		}
	}
	average=sum/(float)n;
	if(average-a[0]>a[n-1]-average)
		printf("%g",a[0]);
	if(average-a[0]==a[n-1]-average)
		printf("%g,%g",a[0],a[n-1]);
	if(average-a[0]<a[n-1]-average)
		printf("%g",a[n-1]);
	return 0;
}


/*
 * sub.cpp
 *
 *  Created on: 2011-12-23
 *      Author: 11229
 */

/*
 * ?????.cpp
 *
 *  Created on: 2011-12-23
 *      Author: 11229
 */
void sort(double arr[100],int len);
int main()
{
	int n,i,imax=0,imin=0;
	cin>>n;
	double sum=0,array[301]={0},average=0,*p=NULL,distant[301]={0},*pdis=distant,
	MAXdis=0,MINdis=100000,maxnum[100]={0},minnum[100]={0},*pmax=maxnum,*pmin=minnum;
	p=array;
	for(i=0;i<n;i++){
		cin>>*(p+i);
		sum+=*(p+i);
	}
	average=sum/(double)(n);
	for(i=0;i<n;i++){
		*(pdis+i)=abs(*(p+i)-average);
		if(*(pdis+i)>MAXdis)MAXdis=*(pdis+i);
		//if(*(pdis+i)<MINdis)MINdis=*(pdis+i);
	}
	for(i=0;i<n;i++){
		if(*(pdis+i)==MAXdis){
			*(pmax+imax)=*(p+i);
			imax++;
		}
		//if(*(pdis+i)==MINdis){
			//*(pmin+imin)=*(p+i);
			//imin++;
		//}
	}
	sort(maxnum,imax);
	//sort(pmin,imin);
	return 0;
}
void sort(double arr[100],int len)
{
	double *pa=arr,temp=0;
	int i,j;
	for(i=0;i<len-1;i++)
		for(j=0;j<len-i-1;j++){
			if(*(pa+j)>*(pa+j+1)){
				temp=*(pa+j);
				*(pa+j)=*(pa+j+1);
				*(pa+j+1)=temp;
			}
		}
	for(i=0;i<len-1;i++)cout<<*(pa+i)<<',';
	cout<<*(pa+len-1);
	cout<<endl;
}


/*
 * sub.cpp
 *
 *  Created on: 2011-12-23
 *      Author: 11229
 */

/*
 * ?????.cpp
 *
 *  Created on: 2011-12-23
 *      Author: 11229
 */
void sort(double arr[100],int len);
int main()
{
	int n,i,imax=0;
	cin>>n;
	double sum=0,array[301]={0},average=0,*p=NULL,distant[301]={0},*pdis=distant,
	MAXdis=0,maxnum[100]={0},*pmax=maxnum;
	p=array;
	for(i=0;i<n;i++){
		cin>>*(p+i);
		sum+=*(p+i);
	}
	average=sum/(double)(n);
	for(i=0;i<n;i++){
		*(pdis+i)=abs(*(p+i)-average);
		if(*(pdis+i)>MAXdis)MAXdis=*(pdis+i);
	}
	for(i=0;i<n;i++){
		if(*(pdis+i)==MAXdis){
			*(pmax+imax)=*(p+i);
			imax++;
		}
	}
	sort(maxnum,imax);
	return 0;
}
void sort(double arr[100],int len)
{
	double *pa=arr,temp=0;
	int i,j;
	for(i=0;i<len-1;i++)
		for(j=0;j<len-i-1;j++){
			if(*(pa+j)>*(pa+j+1)){
				temp=*(pa+j);
				*(pa+j)=*(pa+j+1);
				*(pa+j+1)=temp;
			}
		}
	for(i=0;i<len-1;i++)cout<<*(pa+i)<<',';
	cout<<*(pa+len-1);
	cout<<endl;
}


void main()
{
	int num[300],i,k=0,n,j;
	float aver,sub[300],sum=0;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%d",&num[i]);
		sum=sum+num[i];
	}
	aver=sum/n;
	for (i=0;i<n;i++)
		sub[i]=fabs(num[i]-aver);
	for (i=0;i<n;i++)
		if (sub[i]>sub[k])
			k=i;
	for (i=0;i<n;i++)
		if (sub[i]==sub[k]&&i!=k)
		{
			if (num[i]>num[k])
			{
				j=num[i];
				num[i]=num[k];
				num[k]=j;
			}
			printf("%d,",num[i]);
			break;
		}
	printf("%d\n",num[k]);
}


int main(int argc, char* argv[])
{
	int n,sum=0,a[300];
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum += a[i];
	}
	float aver;
	aver=(float)sum/n;
    int j;
	float b[300];
	for(j=0;j<n;j++)
	{
		if((float)a[j]>aver)
		{
			b[j]=a[j]-aver;
		}
		else
		{
			b[j]=aver-a[j];
		}
	}
	float c;
	c=b[0];
	int m,p=0,q=0;
	for(m=1;m<n;m++)
	{
		if(b[m]>c)
		{
			c=b[m];
			p=m;
		}
	}
	int s;
	for(s=p+1;s<n;s++)
	{
		if(b[s]==c)
		{
			q=s;
		}
	}
	if(q==0)
	{
		printf("%d",a[p]);
	}
	if(q!=0)
	{
		if(a[p]>a[q])
		{
			printf("%d,%d",a[q],a[p]);
		}
		else
		{
			printf("%d,%d",a[p],a[q]);
		}
	}

	return 0;
}


int main(){
	int n,k=0;
	cin>>n;
	float a[n],ar,sum=0,max=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	ar=sum/n;
	for(int i=0;i<n;i++)
		if(abs(a[i]-ar)>=max)max=abs(a[i]-ar);
	for(int i=0;i<n;i++)
		if((abs(a[i]-ar)==max)&&k==0){cout<<a[i];
		k++;
		}
		else if((abs(a[i]-ar)==max)&&k!=0){cout<<','<<a[i];
		k++;
		}
	return 0;
}


int main()
{
	int n,i;int s[300]={0};int max,min;int ave;float ave2;
	scanf("%d",&n);
	scanf("%d",&s[0]);
	ave=s[0];max=s[0];min=s[0];
	for(i=1;i<=n-1;i++)
	{
		scanf("%d",&s[i]);
		if(s[i]>max) max=s[i];
		if(s[i]<min) min=s[i];
		ave=ave+s[i];
	}
	ave2=(float)ave;
	ave2=ave2/n;
	if(fabs((max-ave2)-(ave2-min))<0.001) printf("%d,%d",min,max);
	else if(max+min>2*ave2) printf("%d",max);
	else if(max+min<2*ave2) printf("%d",min);

	return 0;
}


int main()
{
	unsigned int a[300], n, sum = 0;
    double ave, max[100], c, big = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
    ave = (double)sum / n;
	int s = 0;
	for (int j = 0; j < n; j++)
	{
		c = fabs(a[j] - ave);
		if (c == big)
		{
			s++;
			max[s] = a[j];
		}
		if (c > big)
		{
			memset(max, 0, sizeof(max));
			s = 0;
			big = c;
			max[s] = a[j];
		}

	}
	int temp;
	for (int k = 0; k < s; k++)
	{
		for (int p = 0; p < s - k; p++)
		{
			if (max[p] > max[p + 1])
			{
				temp = max[p];
				max[p] = max[p + 1];
				max[p + 1] = temp;
			}
		}
	}
	cout << max[0];
	for (int q = 1; q <= s; q++)
	{
		cout << ',' << max[q] << endl;
	}

	return 0;
}


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

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

	  aver=sum/(double)n;

	 dist=fabs(a[0]-aver);
     for(i=0;i<n;i++)
		if(dist<fabs(a[i]-aver))
			dist=fabs(a[i]-aver);
	for(i=0;i<n;i++)
		if(fabs(dist-fabs(a[i]-aver))<1e-9)
		{printf("%d",a[i]);break;}
	for(j=i+1;j<n;j++)
         if(fabs(dist-fabs(a[j]-aver))<1e-9)
		{printf(",%d",a[j]);}
		printf("\n");
}


int s(int f[],int n)
{
	int i,sum=0;
	for(i=0;i<n;i++)
		sum+=f[i];
	return sum;
}
int dis(int x,int n,int sum)
{
	int tp;
	if((x*n)>sum)
		tp=x*n-sum;
	else
		tp=sum-x*n;
	return tp;
}
int max_d(int d[],int n,int sum)
{
	int i,tp,max=0;
	for(i=0;i<n;i++)
		if(d[i]>max)
			max=d[i];
	return max;
}
void main()
{
	int i,j=0,n,sum,l;
	int f[300],d[300],out[300];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&f[i]);
	sum=s(f,n);
	for(i=0;i<n;i++)
		d[i]=dis(f[i],n,sum);
	l=max_d(d,n,sum);
	for(i=0;i<n;i++)
	{
		if((f[i]*n<sum)&&(d[i]==l))
		{
			out[j]=f[i];
			j++;
		}
	}
	for(i=0;i<n;i++)
	{
		if((f[i]*n>sum)&&(d[i]==l))
		{
			out[j]=f[i];
			j++;
		}
	}
	printf("%d",out[0]);
	for(i=1;i<j;i++)
		printf(",%d",out[i]);
}


int main()
{
    int n,i,j,tem,a[300];
    float ave,b[300],max,sum;
    sum=0;
    scanf("%d",&n);
    for(j=0;j<n;j++)
    {
        scanf("%d",&a[j]);
        sum=sum+a[j];
    }
    ave=sum/n;
    for(i=0;i<n;i++)
    {
        if(a[i]<=ave)
        b[i]=ave-a[i];
        else
        b[i]=a[i]-ave;
    }
    max=b[0];
    for(j=1;j<n;j++)
    {
        if(max<b[j])
        max=b[j];
    }
    for(j=0;j<n;j++)
    {
        if(b[j]==max)
        {
           printf("%d",a[j]);
           tem=j;
           break;
        }
    }
    for(j=tem+1;j<n;j++)
    {
       if(b[j]==max)
        {
           printf(",%d",a[j]);
        }
    }
    return 0;
}


int main(){
	int n;
	double sum=0,ave,max=0;
	cin>>n;
	int a[n],i;
	double b[n],x=0,y=0;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
    ave=sum/n;
    for(i=0;i<n;i++){
    	b[i]=abs(a[i]-ave);
        if(max<b[i]) max=b[i];
    }
    for(i=0;i<n;i++){
    	if (b[i]==max && x==0) x=a[i];
    	if (b[i]==max && x!=0) y=a[i];
    }

    if(x>y) cout<<y<<","<<x;
    if(x<y) cout<<x<<","<<y;
    if(x==y) cout<<x;
    return 0;
}


void main()
{
	unsigned long a[1000], n, i, min, max;
	double ave=0;
	scanf("%d", &n);
	for (i=0;i<n;i++)
	{
		scanf("%d", &a[i]);
	}
	min=a[0];
	max=a[0];
	for (i=0;i<n;i++)
	{
		ave+=a[i];
		if (a[i]<min) min=a[i];
		if (a[i]>max) max=a[i];
	}
	ave/=n;
	double d1=ave-min, d2=max-ave;
	if (fabs(d1-d2)<1e-10)
		printf("%d,%d", min, max);
	else if (d1>d2)
		printf("%d", min);
	else
		printf("%d", max);
}


void main()
{
	int n,i,j,k,total=0,a[300];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	float N,b[300]={0.0000},c[300]={0.0000};
	for(i=0;i<n;i++)
	{
		total=total+a[i];
	}
	N=(float)total/n;
	for(i=0;i<n;i++)
	{
		if(a[i]>=N)b[i]=a[i]-N;
		else c[i]=N-a[i];
	}

    float bmax=0.0000,cmax=0.0000;
	for(i=0;i<n;i++)
		{
			if(b[i]>bmax)
			{
				bmax=b[i];
			  	j=i;
			}
			if(c[i]>cmax)
			{
				cmax=c[i];
				k=i;
	         }
	     }
			if(bmax==cmax)printf("%d,%d",a[k],a[j]);
			else if(bmax>cmax)printf("%d",a[j]);
			else if(cmax>bmax)printf("%d",a[k]);
	return;
}


float average(int a[],int n)
{
	int sum=0,i;
	float avr;
	for(i=0;i<n;i++)
		sum=sum+a[i];
	avr=(float)sum/n;
	return(avr);
}

void main()
{
	int n,a[300],i,num;
	float avr,b[300],t=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	avr=average(a,n);
	for(i=0;i<n;i++)
	{
		if(a[i]>avr)
			b[i]=(float)a[i]-avr;
		else
			b[i]=(float)avr-a[i];
	}
	for(i=0;i<n;i++)
		if(b[i]>t)
		{
			t=b[i];
			num=i;
		}
	printf("%d",a[num]);
	for(i=num+1;i<n;i++)
		if(b[i]==t)
			printf(",%d",a[i]);
	printf("\n");
}


int main()
{
	int n,i,num_min=1,num_max=1;
	float max=-10000,min=10000,a[301],sum=0,ave;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>max)
		{
			max=a[i];
			num_max=1;
		}
		else if(a[i]==max)
		{
			num_max++;
		}
		if(min>a[i])
		{
			min=a[i];
			num_min=1;
		}
		else if(min==a[i])
		{
			num_min++;
		}
		sum+=a[i];
	}
	ave=sum/n;
	if(ave==(max+min)/2)
	{
		for(int t=1;t<=num_min;t++)
			cout<<min<<",";
		for(int t=1;t<num_max;t++)
			cout<<max<<",";
		cout<<max;
	}
	else if(ave<(max+min)/2)
	{
		for(int t=1;t<num_max;t++)
			cout<<max<<",";
		cout<<max;
	}
	else if(ave>(max+min)/2)
	{
		for(int t=1;t<num_min;t++)
			cout<<min<<",";
		cout<<min;
	}

	return 0;
}


int main()
{
    int n;
    double max=0;
    int num[310]={0};
    int out[310]={0};
    double sum=0,avr=0;
    int i=0,j=0,k=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&num[i]);
        sum += num[i];
    }
    avr=sum/n;

    for(i=0;i<n;i++)
    {
        if(fabs(num[i]-avr)>max)
            max=fabs(num[i]-avr);
    }

    //printf("%f \n",max);

    for(i=0;i<n;i++)
    {
        if(max-(fabs(num[i]-avr))<1e-5)
        {
            out[j]=num[i];
            j++;
        }
    }
    for(i=0;i<j-1;i++)
    {
        for(k=0;k<j-i-1;k++)
        {
            if(out[k]>out[k+1])
            {
                int tmp=out[k];
                out[k]=out[k+1];
                out[k+1]=tmp;
            }
        }
    }
    for(i=0;i<j-1;i++)
        printf("%d,",out[i]);
    printf("%d",out[j-1]);
	return 0;
}


void main()
{int n,i,t=0;float s=0;
 int m[300];
 scanf("%d",&n);
 for(i=0;i<n;i++)
  {scanf("%d",&m[i]);
   s=s+m[i];}
 float aver;
 aver=s/n;
  int k=0;
 for(i=1;i<n;i++)
  if(fabs(m[k]-aver)<fabs(m[i]-aver))
     k=i;
 for(i=0;i<n;i++)
  if(fabs(m[k]-aver)==fabs(m[i]-aver))
    {if(t)
     printf(",");
     printf("%d",m[i]);
     if(t==0)
      t++;
     }
}


void main()
{
	double num[300]={0},a[300]={0};
	int i;
	int c=0;
	double max=0;
	double t,ping=0;

	scanf("%lf",&t);

	for(i=0;i<t;i++)
		scanf("%lf",&num[i]);
	for(i=0;i<t;i++)
		ping=ping+num[i];
	ping=ping/t;
	for(i=0;i<t;i++)
		a[i]=fabs(num[i]-ping);
	for(i=0;i<t;i++)
		if(max<a[i])
			max=a[i];
	for(i=0;i<t;i++)
	{
		if(a[i]==max)
		{
			c++;
			if(c==1)
				printf("%.0f",num[i]);
			else
				printf(",%.0f",num[i]);
		}
	}

}


int main()
{
	int n, m = 0;
	float sum = 0, a[500], average, max = -1, aver[250] = {0.1};
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	average = sum / n;
	for(int j = 0; j < n; j++)
	{
		if(fabs(a[j] - average) > max)
		{
			max = fabs(a[j] - average);
		}
	}
	for(int x = 0; x < n; x++)
	{
		if(fabs(fabs(a[x] - average) - max) < 1e-6)
		{
			aver[m] = a[x];
			m += 1;
		}
	}
	for(int k = 0; k < m; k++)
	{
		for(int p = k + 1; p < m; p++)
		{
			if(aver[k] > aver[p])
			{
				double f;
				f = aver[k];
				aver[k] = aver[p];
				aver[p] = f;
			}
		}
	}
	for(int z = 0; z < m; z++)
	{
		cout << aver[z];
		if(z != m - 1)
		{
			cout << ",";
		}
	}
	return 0;
}


void main()
{
	int a[300],n,i,total=0,min,max;

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

    if((total-min*n)==(max*n-total))
		printf("%d,%d\n",min,max);
	else if((max*n-total)>(total-min*n))
		printf("%d",max);
	else
		printf("%d",min);
}


int main()
{
	int n,i,j;
	unsigned a[400]={0},result[400]={0};
	double average=0,maximum=0;
	cin >>n;
	for (i=1;i<=n;i++)
	{
		cin >>a[i];
		average+=a[i];
	}
	average=average/n;//????????
	for (i=1;i<=n;i++)
		if (fabs(a[i]-average)>maximum)
		{
			maximum=fabs(a[i]-average);
			result[0]=1;//result[0]??result?????????
			result[1]=a[i];
		}//?????????????result
		else
			if (fabs(a[i]-average)==maximum)//???????????
			{
				result[0]++;//result[0]??
				result[result[0]]=a[i];//a[i]??result??
			}
	unsigned temp;
	for (i=1;i<result[0];i++)
		for (j=1;j<=result[0]-i;j++)
			if (result[j]>result[j+1])
			{
				temp=result[j];result[j]=result[j+1];result[j+1]=temp;
			}//?result??????
    cout <<result[1];
	for (i=2;i<=result[0];i++)
		cout <<','<<result[i];//??
	return 0;
}


void main()
{
	int n;
	int a[302]={0},r[301]={0};
	int i,j,count=0,tag=0,temp;
	float aver,max=0,sum=0,t;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(i=0;i<n;i++)
		sum+=a[i];
	aver=sum/n;

    for(i=0;i<n;i++)
	{
		if(fabs(a[i]-aver)>max)
		  max=fabs(a[i]-aver);
	}

	for(i=0;i<n;i++)
	{
	    t=fabs(a[i]-aver);
		if(t==max)
		{

			r[count]=a[i];
			count++;
		}
	}

	for(i=0;i<count;i++)
	{
		tag=r[i];
		for(j=i;j<count;j++)
		{
			if(r[j]<tag)
			{
				tag=r[j];
			}
		}
		if(tag!=r[j])
		{
			temp=r[i];
			r[i]=r[j];
			r[j]=temp;
		}
	}
	if(count==1)
		printf("%d",r[1]);
else
{
	for(i=1;i<count;i++)
		printf("%d,",r[i]);
	printf("%d\n",r[i]);
}
}


int main()
{
	int n,i,j,a[300],t=0;
	float s=0,aver,max,temp;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++)
	{
		s=s+a[i];
	}
	aver=s/n;
	for(i=0;i<n-2;i++)
	{
		for(j=0;j<n-i-1;j++)
		{
			if(a[j]>a[j+1])
			{
				temp=a[j];
				a[j]=a[j+1];
				a[j+1]=temp;
			}
		}
	}
	max=aver-a[0];
	for(i=0;i<n;i++)
	{
		if(a[i]<aver) temp=aver-a[i];
		else temp=a[i]-aver;
		if(temp>max)
			max=temp;
	}
	for(i=0;i<n;i++)
	{
		if(a[i]<aver) temp=aver-a[i];
		else temp=a[i]-aver;
		if(temp==max)
		{
			t=t+1;
			if(t==1)
				printf("%d",a[i]);
			else
				printf(",%d",a[i]);
		}
	}
	return 0;
}


main()
{
int n, num, k , max=-1, min=100000, sum=0;
scanf("%d",&n);
for(k=0; k<n; ++k)
{scanf("%d",&num);
sum=sum+num;
if(num>max) max=num;
if(num<min) min=num;
}
if((max*n-sum)==(sum-min*n)) printf("%d,%d",min,max);
else if ((max*n-sum)>(sum-min*n)) printf("%d", max);
else printf("%d",min);
}


int main()
{
	int n;
	cin >> n;
	int i , j;
	double num[400] = {0.0};
	double num2[400] = {0.0};

	double sum = 0.0;
	double ave = 0.0;
	int counter = 0;
	for( i = 0 ; i <= n - 1 ; i ++ )
	{
		cin >> num[i];
		sum = sum + num[i];
	}
    ave = sum / n;
	double Max = 0.0 , temp = 0.0;
	for( i = 0 ; i <= n - 1 ; i ++ )
	{
		temp = fabs( num[i] - ave );
		if( temp > Max )
			Max = temp;
	}
	for( i = 0 ; i <= n - 1 ; i ++ )
		if(  fabs( fabs( num[i] - ave ) - Max ) <= 0.00001 )
		{
			num2[counter] = num[i];
			counter ++;
		}
	if( counter == 1 )
		cout << num2[0];
	else
	{
		for( i = 0 ; i <= counter - 2 ; i ++ )
			for( j = i + 1 ; j <= counter - 1 ; j ++ )
			{
				if( num2[i] > num2[j] )
				{
					temp = num2[i];
					num2[i] = num[j];
					num[j] = temp;
				}
			}
		cout << num2[0];
		for( i = 1 ; i <= counter - 1 ; i ++ )
			cout << "," << num2[i];
	}

	return 0;
}


void main(){
  int n,a[300],i,min,max;
  float ave,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
   scanf("%d",&a[i]);
   sum=sum+a[i];
  }
  ave=sum/n;
  max=a[0];
  min=a[0];
    for(i=0;i<n;i++)
  {
   if(a[i]>max)
   max=a[i];
  }
      for(i=0;i<n;i++)
  {
   if(a[i]<min)
   min=a[i];
  }

  if((max+min)>2*ave)
  printf("%d",max);
  else if((max+min)<2*ave)
  printf("%d",min);
  else
  printf("%d,%d",min,max);

     }


/*
 * y1.cpp
 *
 *  Created on: 2011-1-9
 *      Author: jsgl
 */
float tran(float x){
	if(x<0)return -x;
	else return x;
}
int main(){
	int n,i,B=0;
	float p,m,a[301],s=0,b[301];
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
        s+=a[i];
}
     p=s/n;
     b[0]=tran(a[0]-p);
     m=b[0];
     for(i=1;i<n;i++){
    	 b[i]=tran(a[i]-p);
    	 if(b[i]>m)
    	 m=b[i];
    	}

     for(i=0;i<n;i++)
    	 if(b[i]==m)
    		if(B)cout<<","<<a[i];
    		else { cout<<a[i];
    		    	 B++;}

     return 0;
}


int main()
{
	int n,i,j,num[310],sum,t;
	double aver;
	scanf("%d",&n);
	sum=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&num[i]);
		sum+=num[i];
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n-i-1;j++)
		{
			if(num[j]>num[j+1])
			{
				t=num[j];
				num[j]=num[j+1];
				num[j+1]=t;
			}
		}
	}
	aver=(sum*1.0)/n;
	if(num[n-1]-aver>aver-num[0])
		printf("%d",num[n-1]);
	else{
		if(num[n-1]-aver==aver-num[0])
			printf("%d,%d",num[0],num[n-1]);
		else printf("%d",num[0]);
	}
	return 0;
}


int num[310];
int main()
{
	int n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>num[i];
		sum=sum+num[i];
	}

	double ave=sum/(n*1.0);
	double away[310];

	int use;

    for(int i=1;i<=n;i++)
		away[i]=abs(num[i]*1.0-ave);

	double use2;
	for(int i=1;i<=n-1;i++)
		for(int j=1;j<=n-i;j++)
			if(away[j]<away[j+1])
			{ use2=away[j];away[j]=away[j+1];away[j+1]=use2;
	          use=num[j];num[j]=num[j+1];num[j+1]=use;
	       }

    int m;
	for(int i=1;i<=n;i++)
		if(away[i+1]!=away[i])
		  {m=i;break;}

	for(int i=1;i<=m-1;i++)
		for(int j=1;j<=m-i;j++)
			if(num[j]>num[j+1])
			{ use=num[j];num[j]=num[j+1];num[j+1]=use; }

	for(int i=1;i<=m-1;i++)
		cout<<num[i]<<",";
	cout<<num[m];

	return 0;
}


int main()
{
	int n , i , j , p = 0 ;
	double	num[ 11111 ] , s = 0 , max = 0 , t ;

	cin >> n ;

	for( i = 1 ; i <= n ; i ++ )
	{
		cin >> num[ i ] ;

		s = s + num[ i ] ;
	}

	s = s / n ;

	for( j = 1 ; j <= n ; j ++ )
		for( i = j ; i <= n - j ; i ++ )
			if( num[ i ] > num[ i + 1 ] )
			{
				t = num[ i ] ;
				num[ i ] = num[ i + 1 ] ;
				num[ i + 1 ] = t ;
			}

	for( i = 1 ; i <= n ; i ++ )
		if( max <= fabs( num[ i ] - s ) )
			max = fabs( num[ i ] - s ) ;

	for( i = 1 ; i <= n ; i ++ )
		if( max - fabs( num[ i ] - s ) < 0.0001 )
		{
			if( p == 0 )
			{
				cout << num[ i ] ;
				p = 1 ;
			}

			else
				cout << "," << num[ i ] ;
		}

	return 0 ;
}


int main()
{
	int num, i, c[301] = {0}, t = 300, flag = 0;
	double aver, a[301], b[301] = {0}, sum = 0.0, max;
	cin >> num;
	for (i = 0; i < num; i++)
	{
		cin >> a[i];
		sum = sum + a[i];
	}
	aver = sum / (double)num;
	max = 0;
	for (i = 0; i < num; i++)
	{
		b[i] = fabs(a[i] - aver);
		if ((b[i] - max) > 0)
		{

			max = b[i];
			c[t] = 0;
			t = i;
			c[i] = 1;
		}
	}
	for (i = 0; i < num; i++)
	{
		if (c[i] == 1 || fabs((double)b[i] - max) < 1e-9)
		{
			if (flag == 0)
			{
				cout << a[i];
				flag++;
			}
			else
				cout << "," << a[i];
		}
	}
	cin >> i;
	return 0;
}


int main()
{
	int n, i, num[301], maxnum = 0, minnum = 0;
	double sub, sum = 0, average, max = 0, min = 0;
	cin >> n;
	for(i = 1; i <= n; i++)
	{
		cin >> num[i];
		sum += num[i];
	}
	average = sum / n;
	for(i = 1; i <= n; i++)
	{
		sub = num[i] - average;
		if(sub > max)
		{
			max = sub;
			maxnum = i;
		}
		if(sub < min)
		{
			min = sub;
			minnum = i;
		}
	}
	min *= -1;
	if(max == min)
	{
		cout << num[minnum] << "," << num[maxnum] << endl;
	}
	if(max < min)
	{
		cout << num[minnum] << endl;
	}
	if(max > min)
	{
		cout << num[maxnum] << endl;
	}
	return 0;
}


void main()
{
	int n,i,a[100],flag1,flag2=-1;
	double ave,sum=0.0,max=0.0,b[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	ave=(double)sum/n;
	for(i=0;i<n;i++)
	{b[i]=fabs(a[i]-ave);
	if(b[i]>max)
	{flag1=i,max=b[i];}
	if(b[i]==max)
		flag2=i;}
	if(flag2==1||flag1==flag2)
		printf("%d",a[flag1]);
	else if(a[flag1]-ave<0)
		printf("%d,%d",a[flag1],a[flag2]);
	else
		printf("%d,%d",a[flag2],a[flag1]);
return 0;
}


/*
 * 2011-1-9.cpp
 *
 *  Created on: 2011-1-9
 *      Author: jsgl
 */
int main()
{
	int n;
	cin>>n;
	int a[n],i;
	double m,sum=0;
	for (i=0;i<n;i++)
	{
		cin>>a[i];
		sum=sum+a[i];
	}
	m=sum/n;

	int max=a[0],min=a[0];
	for (i=0;i<n;i++)
	{
		if (a[i]>max)
			max=a[i];
	}
	for (i=0;i<n;i++)
		{
			if (a[i]<min)
				min=a[i];
		}
	if ((max-m)==(m-min))
		cout<<min<<','<<max;
	if ((max-m)>(m-min))
		cout<<max;
	if ((max-m)<(m-min))
			cout<<min;
	return 0;

}


float juedui(float x)
{
	if(x>=0)
	{
		return x;
	}
	else
	{
		return (-1*x);
	}
}
int main()
{
	int x[100];
	int n;
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&x[i-1]);
	}
	float aver=0;
	for(i=1;i<=n;i++)
	{
		aver+=x[i-1];
	}
	aver/=n;
	float max=x[0]-aver;
	for(i=1;i<=n;i++)
	{
		if(max<juedui(x[i-1]-aver))
		{
			max=juedui(x[i-1]-aver);
		}
		else
		{}
	}
	int count=0;
	for(i=1;i<=n;i++)
	{
		if(juedui(x[i-1]-aver)==max)
		{
			if(count==0)
			{
				printf("%d",x[i-1]);
			}
			else
			{
				printf(",%d",x[i-1]);
			}
			count++;
		}
		else
		{}
	}
	return 0;
}


void main()
{
	int i,n,num[300],sum=0,real=0;
	double aver,cha=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&num[i]);
		sum=sum+num[i];
	}
	aver=(double)sum/n;
	for(i=0;i<n;i++)
		cha=(fabs(num[i]-aver)>cha)?fabs(num[i]-aver):cha;
	for(i=0;i<n;i++)
	{
		if((fabs(fabs(num[i]-aver)-cha)<=0.00001)&&(real==0))
		{printf("%d",num[i]);
		real=1;}
		else if(fabs(fabs(num[i]-aver)-cha)<=0.00001)
			printf(",%d",num[i]);
	}
}


void main()
{
	int max,min,x,i,n,s=0;
	scanf("%d",&n);
	scanf("%d",&max);
	min=max;
	s=max;
	for(i=1;i<n;i++)
	{scanf("%d",&x);
	if(x>max)max=x;
	else
		if(x<min)min=x;
	s=s+x;}
	if(abs(min*n-s)==abs(max*n-s))printf("%d,%d",min,max);
	else
		if(abs(min*n-s)<abs(max*n-s))printf("%d",max);
		else printf("%d",min);
}


int main()
{
	double a[320]={0};
	double sum=0;
	int num=0;
	int i,j;
	double average=0;
	double b[320]={0},t;
	double c[400]={0};
	double max=0;
	double n;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		sum=sum+a[i];
	}
	//cout<<sum;
	average=sum/n;
	//cout<<average;
	for(i=0;i<n;i++)
	{
		b[i]=fabs(a[i]-average);
		//cout<<"b"<<i<<b[i]<<" ";
		if(max<b[i])
			max=b[i];
	}
	//cout<<"max "<<max;
	for(i=0;i<n;i++)
	{
		if(b[i]==max)
		{
			c[num]=a[i];
			num++;
		}
	}
	//cout<<"check "<<c[0]<<" "<<c[1]<<endl;
	for(i=0;i<num-1;i++)
		for(j=0;j<num-i-1;j++)
		{
			if(c[j]>c[j+1])
			{
				t=c[j];
				c[j]=c[j+1];
				c[j+1]=t;
			}
		}
	cout<<c[0];
	for(i=1;i<num;i++)
		cout<<","<<c[i];
	return 0;
}


int main ()
{
	int n;
	int a[310]={0};
	cin>>n;
	int sum = 0;
	for (int i=0;i<n;i++){
		cin>>a[i];
		sum += a[i];
	}
	double average = (double)sum/(double)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 t;
				t = a[j]; a[j] = a[j+1]; a[j+1] = t;
			}
	int maxp[310]={0},num = 0;
	double dmax = 0;
	for (int i=0;i<n;i++){
		double d = fabs((double)a[i]-average);
		if (d > dmax)
			dmax = d;
	}
	for (int i=0;i<n;i++){
		double d = fabs((double)a[i]-average);
		if (fabs(d-dmax)<1e-8)
			maxp[num++] = i;
	}
	for (int i=0;i<num-1;i++)
		cout<<a[maxp[i]]<<",";
	cout<<a[maxp[num-1]];
	return 0;
}


int n;
int num[100];
int i;
int min=10000,max=-1,total=0;
int main(void)
{
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&num[i]);
		if(num[i]<min)
			min=num[i];
		if(num[i]>max)
			max=num[i];
		total+=num[i];
	}
	if(total-min*n==max*n-total)
		printf("%d,%d\n",min,max);
	else
		if(total-min*n<max*n-total)
		{
			printf("%d\n",max);
		}
		else if(total-min*n>max*n-total)
			printf("%d\n",min);
}


void main()
{
	int n,i,max,min,p;
	float av,sum=0,a[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%f",&a[i]);
	for(i=0;i<n;i++)
		sum=sum+a[i];
	av=sum/n;
	max=min=a[0];
	for(i=1;i<n;i++)
	{
		max=a[i]>max?a[i]:max;
		min=a[i]>min?min:a[i];
	}
	p=max+min;
	if(2*av==p)
		printf("%d,%d\n",min,max);
	else if(2*av>p)
		printf("%d\n",min);
	else if(2*av<p)
		printf("%d\n",max);
}


const double MIN=0.000001;
int main()
{
	int n,number[301];
	int i,j,t;
	double sum=0,average;
	cin>>n;
	for (i=0;i<n;i++)
	{
		cin>>number[i];
		sum+=number[i];
	}
	average=sum/n;
	for (i=0;i<n-1;i++)
	{
		for (j=i+1;j<n;j++)
		{
			if (number[i]>number[j])
			{
				t=number[i];
				number[i]=number[j];
				number[j]=t;
			}
		}
	}
	if (average-number[0]==number[n-1]-average)
		cout<<number[0]<<","<<number[n-1]<<endl;
	else if (average-number[0]>number[n-1]-average)
		cout<<number[0]<<endl;
	else if (average-number[0]<number[n-1]-average)
		cout<<number[n-1]<<endl;
	return 0;
}


int main ()
{  int i,m,n,sum=0,max,min;
   int num[300];
   scanf("%d",&n);
   for(i=0;i<n;i++)
	  { scanf("%d",&num[i]);
         sum+=num[i];
	  }
   max=num[0];
   min=num[0];
   for(i=0;i<n;i++)
   {  if(num[i]>max) max=num[i];
      if(num[i]<min) min=num[i];
   }
   m=2*sum-n*(max+min);
   if(n==1) printf("%d",num[0]);
   if(m>0) printf("%d",min);
   if(m==0&&n!=1) printf("%d,%d",min,max);
   if(m<0) printf("%d",max);
   return 0;
}


/*
 * 1.cpp
 *
 *  Created on: 2011-1-9
 *      Author: jsgl
 */
int main()
{
	int n, i, max, min;
	double sum, k;
	int a[305];
	cin>>n;
	cin>>a[0];
	max=min=a[0];
	sum=a[0];
	for(i=1; i<n; i++)
	{
		cin>>a[i];
		sum=sum+a[i];
		if(a[i]>max) max=a[i];
		if(a[i]<min) min=a[i];
	}
	k=(double)sum/n;
    if((max-k)>(k-min)) cout<<max;
    else if((max-k)<(k-min)) cout<<min;
    else cout<<min<<","<<max;
	return 0;
}


void main()
{
	int n;
	int i,j;
	int tem;
	int ori[301];
	float sum=0,E=0;

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&ori[i]);
	}
	for(i=0;i<n-1;i++)
		for(j=1;j<n-i;j++)
		{
			if(ori[j]<ori[j-1])
			{
				tem=ori[j-1];ori[j-1]=ori[j];ori[j]=tem;
			}
		}
	for(i=0;i<n;i++)
	{
		sum+=ori[i];
	}
	E=sum/n;
	if(0.001>fabs((float)(ori[0]+ori[n-1])/2-E))
	     printf("%d,%d\n",ori[0],ori[n-1]);
	else if(E<(ori[0]+ori[n-1])/2.0)
		printf("%d\n",ori[n-1]);
	     else
			 printf("%d\n",ori[0]);
}


int main()
{
	int n,a[300],i,sum=0,m=0,c[2],j=0;
	float aver,cha[300],max;
	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;i++)
	{
		if(a[i]>aver)
			cha[i]=(float)(a[i]-aver);
		else
			cha[i]=(float)(aver-a[i]);
	}
	for(i=0;i<n;i++)
	{
		if(cha[i]>max)
			max=cha[i];
	}
	for(i=0;i<n;i++)
	{
		if(cha[i]==max)
		{
			c[j]=a[i];
			j++;
			m++;

		}
	}
	if(m==1)
		printf("%d\n",c[0]);
	else
		printf("%d,%d\n",c[0],c[1]);
}


int main()
{
	double a[302], b[302] = {0};
	double num = 0, average = 0, k;
	int n, p = 0, i, j;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
		num = num + a[i];
	}
	average = num / n;
	k = fabs(a[0] - average);
	for (i = 0; i < n; i++)
	{
		if (fabs(a[i] - average) > k)
		{
			p = 1;
			k = fabs(a[i] - average);
			b[p] = a[i];
		}
		else
			if (fabs(a[i] - average) == k)
			{
				p++;
				b[p] = a[i];
			}
	}
	for (i = 1; i <= p; i++)
	{
		for (j = 1; j <= p - i; j++)
		{
			if (b[j] > b[j + 1])
			{
				k = b[j];
				b[j] = b[j + 1];
				b[j+ 1] = b[j];
			}
		}
	}
	for (i = 1; i <= p; i++)
	{
		if (i == 1)
			cout << b[i];
		else
			cout << "," << b[i];
	}
	cout << endl;
	return 0;
}


void main()
{
	int num,n[300],max,min,x,y,i;
	float av=0;
          scanf("%d",&num);
	for(i=0;i<num;i++)
	{
		scanf("%d",&n[i]);av+=n[i];
	}
	max=n[0];
	x=1;
	av/=num;
	for(i=1;i<num;i++)
	{
	if(n[i]>max)
	{max=n[i];x=1;}
	else
	{
	if(n[i]==max)x++;
	}
	}

    min=n[0];
	y=1;
	for(i=1;i<num;i++)
	{
		if(n[i]<min)
		{
			min=n[i];y=1;
		}
		else
		{
			if(min==n[i])y++;
		}
	}
	if(min==max)
	{
		printf("%d",max);
		for(i=1;i<x;i++)
			printf(",%d",max);
	}
	else
	{
		if((max+min)==(2*av))
		{
			printf("%d",min);
			for(i=1;i<y;i++)
				printf(",%d",min);

			for(i=0;i<x;i++)
				printf(",%d",max);
		}
		else
		{
			if((max+min)>(av*2))
			{
				printf("%d",max);
				for(i=1;i<x;i++)
					printf(",%d",max);
			}
			else
			{
				printf("%d",min);
				for(i=1;i<y;i++)
					printf(",%d",min);
			}
		}
	}
}


int main()
{
	int count = 0, flag = 0;
	int i, j ;
	double x = 0.0, max = 0.0, num[301], n, temp, b[301] = {0};
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> num[i];
		x = x + num[i];
	}
	x = x / n;
	for (i = 0; i < n - 1; 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;
			}
		}
	}
	for (i = 0; i < n; i++)
	{
		if (num[i] >= x)
			b[i] = num[i] - x;
		else
			b[i] = x - num[i];
	}
	for (i = 0; i < n; i++)
	{
		if (max < b[i])
			max = b[i];
	}
	for (i = 0; i < n; i++)
	{
		if (b[i] == max)
		{
			if (flag == 0)
			{
				cout << num[i];
				flag = 1;
			}
			else
				cout << ',' << num[i];
		}
	}
	return 0;
}


int main()
{
	int a[300],i,n,max,min;
	double aver,cha1,cha2,sum=0.0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	aver=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];
	}
	cha1=fabs(max-aver);
	cha2=fabs(min-aver);
	if(cha1==cha2)
		printf("%d,%d",min,max);
	else
	{
		if(cha1>cha2)
			printf("%d",max);
		else
			printf("%d",min);
	}
	return 0;
}


/*
 * 1234.cpp
 *
 *  Created on: 2011-1-9
 *      Author: c130
 */
int main()
{
	int n,i;
	float a[300],max,min,s=0;
	float v,w,e;
	cin >> n;
	for(i=0;i<n;i++)
		cin >> a[i];
	max=a[0];
	min=a[0];
	for(i=0;i<n;i++)
		if(a[i]>max)
			max=a[i];
	for(i=0;i<n;i++)
			if(a[i]<min)
				min=a[i];
	for(i=0;i<n;i++)
			s=s+a[i];
	v=s/n;
	w=v-min;
	e=max-v;
	if(w>e)
		cout << min << endl;
	else
		if(w==e)
			cout << min << "," << max << endl;
			else
				cout << max << endl;
	return 0;
}


int main()
{
	int n, i;
	double num[300], sum = 0, min = 10000, max = 0, temp = 0;
	double aver;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> num[i];
		sum += num[i];
	}
	aver = 1.0 * sum / n;
	for (i = 0; i < n; i++)
	{
		if (fabs(num[i] - aver) >= temp)
		{
			temp = num[i] - aver;
			if (num[i] >= max)
				max = num[i];
			if (num[i] <= min)
				min = num[i];
		}
	}
	if (min == max)
		cout << min << endl;
	else if ((max - aver) - (aver - min) > 0)
		cout << max << endl;
	else if ((max - aver) - (aver - min) < 0)
		cout << min << endl;
	else
		cout << min << "," << max << endl;
	return 0;
}


void f1(float a[],int x);
void main()
{
	int n;
	float shuzu[1000],ping;
	float max,min,sum=0;
	int s;
	scanf("%d",&n);
	for (s=0;s<n;s++)
	{
		scanf("%f",&shuzu[s]);
	}
	f1(shuzu,n);
	for (s=0;s<n;s++)
	{
		sum=sum+shuzu[s];
	}
	ping=sum/n;
	max=shuzu[0]-ping;
	min=ping-shuzu[n-1];
	if(max==min) printf("%.0f,%.0f",shuzu[n-1],shuzu[0]);
	else if(max>min) printf("%.0f",shuzu[0]);
	else printf("%.0f",shuzu[n-1]);
}
void f1(float a[],int x)
{
	int i,j;
	float t;
	for (i=0;i<x-1;i++)
	{
		for (j=0;j<x-1;j++)
		{
			if(a[j]<a[j+1])
			{
				t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;
			}
		}
	}
}


int main()
{
	int a[300]={0},b[300]={0},i,j,n,s;
	float sum=0,aver,demin,demax;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++)
	{
		sum=sum+a[i];
		s=0;
		for(j=0;j<n;j++)
		{
			if(a[i]>a[j])
				s++;
		}
		b[s]=a[i];
	}
	aver=sum/n;
	demin=aver-b[0];
	demax=b[n-1]-aver;
	if(demin==demax)
		printf("%d,%d",b[0],b[n-1]);
	if(demin>demax)
		printf("%d",b[0]);
	if(demin<demax)
		printf("%d",b[n-1]);
	return 0;
}


int main()
{
	unsigned int *p,*k;
	int n,i,j=0,t,m=0,tmp;
	double a=0,sum=0,*c,lar=0;
	scanf("%d",&n);
	p=(unsigned int*)malloc(sizeof(unsigned int)*n);
	c=(double*)malloc(sizeof(double)*n);
	k=(unsigned int*)malloc(sizeof(unsigned int)*n);
	for(i=0;i<n;i++)
	{
		scanf("%u",&p[i]);
		sum=sum+(double)p[i];
	}
	a=sum/(double)n;
	for(i=0;i<n;i++)
	{
		if(a-(double)p[i]>=0)
			c[i]=a-(double)p[i];
		else
			c[i]=(double)p[i]-a;
	}
	for(i=0;i<n;i++)
	{
		if(lar<c[i])
		{
			lar=c[i];
		}
	}
	for(i=0;i<n;i++)
	{
		if(c[i]==lar)
		{
			k[j]=p[i];
			j++;
		}
	}
	m=j;
	for(i=0;i<m;i++)
	{
		t=i;
		for(j=m-1;j>i;j--)
		{
			if(k[j]>k[j-1])
				t=j-1;
		}
		tmp=k[i];
		k[i]=k[t];
		k[t]=tmp;
	}
	printf("%u",k[0]);
	for(i=1;i<t+1;i++)
		printf(",%u",k[i]);
	free(p);
	free(k);
	free(c);
	return 0;
}


//Define Head files
int a[501];//Array of Elements
int main()
{
	int n,x;
	double avr=0;
	cin>>n;
	for(x=1;x<=n;x++)
	{
		cin>>a[x];
		avr+=a[x];
	}
	avr=avr/n;
	//Input Fin
	sort(&a[1],&a[n]+1);

	/*for(x=1;x<=n;x++)  cout<<a[x]<<' ';
	cout<<endl<<avr;
	*/

	if ( avr-a[1]>a[n]-avr )
	{
		cout<<a[1]<<endl;
	}
	else if ( avr-a[1] ==a[n]-avr )
	{
		cout<<a[1]<<','<<a[n]<<endl;
	}
	else cout<<a[n]<<endl;

	return 0;
}


int main()
{
	int n,a[max],tmp,i,j;
	float ave,sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	ave=(float)sum/n;
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(fabs(a[i]-ave)<fabs(a[j]-ave)){
				tmp=a[i];
				a[i]=a[j];
				a[j]=tmp;
			}
		}
	}

	printf("%d",a[0]);
	i=1;
	while(fabs(a[i]-ave)==fabs(a[0]-ave)){
		printf(",%d",a[i]);
		i++;
	}
	return 0;
}


void main()
{
	int n,i,k,m=0,*a,*c;
	double t,s=0,*b;
	scanf("%d",&n);
	a=(int *)malloc(sizeof(int)*n);
	b=(double *)malloc(sizeof(double)*n);
	c=(int *)malloc(sizeof(int)*n);

	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		s+=a[i];
	}
	s=s/n;
	for(i=0,t=0;i<n;i++)
	{
		b[i]=fabs(a[i]-s);
		if(b[i]>t) t=b[i];
	}
	for(i=0;i<n;i++)
	{
		if(b[i]==t)
		{
			c[m]=a[i];
			m++;
		}
	}
	for(i=0;i<m-1;i++)
		printf("%d,",c[i]);
	printf("%d",c[m-1]);
	free(a);
	free(b);
	free(c);
}


void main()
{
	int n;
	int m[300];
	int i,j;
	int b;
	int sum=0,temp;
	float ave;

	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&m[i]);
	for(i=0;i<n;i++)
		sum=sum+m[i];
	ave=(float)sum/(float)n;
	for (i=1;i<n-1;i++)
	{
		for (j=0;j<n-i;j++)
		{
			if (m[j]>m[j+1])
			{
				temp=m[j];
				m[j]=m[j+1];
				m[j+1]=temp;
			}
		}
	}
	if ((ave-(float)m[0])>((float)m[n-1]-ave))
		printf("%d",m[0]);
	else if ((ave-(float)m[0])<((float)m[n-1]-ave))
		printf("%d",m[n-1]);
	else
		printf("%d,%d",m[0],m[n-1]);
}


int main()
{
int n,array[1000];
float sum=0;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
	scanf("%d",&array[i]);
}
for(int i=0;i<n;i++)
{
	sum+=array[i];
}
sum=sum/n;
sort(array,array+n);
if(sum-array[0]*1.0>array[n-1]*1.0-sum){printf("%d",array[0]);}
if(sum-array[0]*1.0==array[n-1]*1.0-sum){printf("%d,%d",array[0],array[n-1]);}
if(sum-array[0]*1.0<array[n-1]*1.0-sum){printf("%d",array[n-1]);}
	return 0;
}


struct num
{   int n;
	float d;
};
int main()
{	int n,i,j,sum=0;
	float aver;
	struct num nob[300],temp;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&nob[i].n);
		sum+=nob[i].n;
	}
	aver=(sum*1.0)/(n*1.0);
	for(i=0;i<n;i++)
		nob[i].d=nob[i].n>aver?(nob[i].n-aver):(aver-nob[i].n);
	for(i=0;i<n-1;i++)
	{
		for(j=0;j<n-1-i;j++)
			if(nob[j].d<nob[j+1].d)
			{
				temp=nob[j];
				nob[j]=nob[j+1];
				nob[j+1]=temp;
			}
	}

	sum=1;
	for(i=1;i<n;i++)
	{
		if(nob[0].d==nob[i].d) sum++;
		else break;
	}
	if(sum==1)printf("%d\n",nob[0].n);
	else
	{
		for(i=0;i<sum-1;i++)
			for(j=0;j<sum-1-i;j++)
			if(nob[j].n>nob[j+1].n)
			{
				temp=nob[j];
				nob[j]=nob[j+1];
				nob[j+1]=nob[j];
			}
	printf("%d",nob[0].n);
	for(i=1;i<sum;i++)
		printf(",%d",nob[i].n);
	}
	return 0;
}


struct number
{
    unsigned int shuzi;
	float pianli;
};

int main()
{
int i,j,n;
float average,sum=0;
scanf("%d",&n);

struct number num[301],t;

for(i=0;i<n;i++)
	scanf("%d",&num[i].shuzi);
for(i=0;i<n;i++)
sum=sum+num[i].shuzi;
average=sum/(float)n;
for(i=0;i<n;i++)
num[i].pianli=fabs(num[i].shuzi-average);
for(j=0;j<n;j++)
for(i=0;i<n-j-1;i++)
{if(num[i].pianli>num[i+1].pianli)
{
	t=num[i];
	num[i]=num[i+1];
	num[i+1]=t;
}
else
{
	if(num[i].pianli==num[i+1].pianli)
{ if(num[i].shuzi>num[i+1].shuzi)
	  { 	t=num[i];
	num[i]=num[i+1];
	num[i+1]=t;}
}
}
}

for(i=0;i<n-1;i++)
{

	if(num[i].pianli==num[n-1].pianli)
	{printf("%d,", num[i].shuzi);}

}
	printf("%d", num[n-1].shuzi);

return 1;
	}


int main()
{
	int n,i,max,sum=0,b1=0,b2=0;
	float ave;
	unsigned int a[300];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	ave=(float)sum/n;
	max=0;
	for(i=0;i<n;i++){
		if(fabs(a[i]-ave)>=max){
			if(a[i]<ave){
				max=fabs(a[i]-ave);
				b1=i;
			}
			else{
				max=fabs(a[i]-ave);
				b2=i;
			}
		}
	}
	if((a[b2]-ave)>(ave-a[b1])) printf("%d",a[b2]);
	else if((a[b2]-ave)<(ave-a[b1])) printf("%d",a[b1]);
	else printf("%d,%d",a[b1],a[b2]);
	return 0;
}


int main()
{  int n;
   int c[300];

  scanf("%d",&n);
  int i; int sum=0;
  for(i=0;i<n;i++)
  {
	  scanf("%d",&c[i]);
  sum+=c[i];

  }
  double b;
  b=(double)sum/n;
  double largest=0;
  double  d[300]={0};
  for(i=0;i<n;i++)
  {
  if(c[i]>b)
  d[i]=(double)c[i]-b;
  else
  {
   d[i]=b-(double)c[i];
  }
  if(d[i]>largest)
	  largest=d[i];
  }

  int j; int e;double m;
  for(i=0;i<n;i++){
	  for(j=n-1;j>i;j--)
	  {
		  if(c[j]<c[j-1])
		  { e=c[j-1];
         c[j-1]=c[j];
		 c[j]=e;
		 m=d[j-1];
         d[j-1]=d[j];
		 d[j]=m;

		  }

	  }

  }

  for(i=0;i<n;i++)
  {
     if(d[i]==largest)
	 {printf("%d",c[i]);
	 d[i]=0;
	 break;}

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

  }

   return 0;

}


void main()
{
	int n,i,all=0;
	float ave,cha=0,a[300],sum=0,chan[300];
	scanf("%d",&n);
	for(i=0;i<=n-1;i++)
	{
		scanf("%f",&a[i]);
		sum+=a[i];
	}
	ave=sum/n;
	//printf("%f",ave);
	for(i=0;i<=n-1;i++)
	{
		chan[i]=fabs(ave-a[i]);
		//printf("%f",chan[i]);
		if(chan[i]>cha)
		{
			cha=chan[i];
		}
	}
	for(i=0;i<=n-1;i++)
	if(chan[i]==cha)
		all++;
	for(i=0;i<=n-1;i++)
	{if(chan[i]==cha&&all!=1)
	{
		printf("%.0f,",a[i]);
		all--;
	}
	else if(chan[i]==cha&&all==1)
		printf("%.0f",a[i]);}
	getchar();
	getchar();
}


void main()
{
	int i,n,x[300],max,min,s=0;
	float aver;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&x[i]);
	for(i=0;i<n;i++)
	{
		s=s+x[i];
	}
	aver=s*1.0/n;
	max=x[0];min=x[0];
	for(i=1;i<n;i++)
	{
		if(x[i]>max)
			max=x[i];
		else if(x[i]<min)
			min=x[i];
	}
	if(max==min)printf("%d",min);
	else if((max-aver)>(aver-min))
		printf("%d",max);
	else if((max-aver)<(aver-min))
		printf("%d",min);
	else
		printf("%d,%d",min,max);
}


/*
 * 1234.cpp
 *
 *  Created on: 2011-1-9
 *      Author: jsgl
 */
int main()
{
	int i,c=0,t=0,n;
	double sum=0;
	double a[301],b[301];
	double s;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<n;i++)
		sum+=a[i];
	s=sum/n;
	double max=0;
	for(i=0;i<n;i++)
	{ if(abs(s-a[i])>=max)
		max=abs(s-a[i]);
	}
	for(i=0;i<n;i++)
	{  if(abs(s-a[i])==max) {b[t++]=a[i];
        c++;}
	}
	for(i=0;i<c-1;i++)
		cout<<b[i]<<",";
	cout<<b[c-1]<<endl;

	return 0;
}


int main()
{
	int a[300],b[300]={1};
	int n,i,j,count=0;
	double total=0.0,result=0.0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		total+=a[i];
	}
	result=total/n;
	double max=0.0;
	for(i=0;i<n;i++)
	{
		if((double)fabs((a[i]-result))-max>0.00001)
			max=fabs(a[i]-result);
	}
	for(i=0,j=0;i<n;i++)
	{
		if(fabs(fabs(a[i]-result)-max)<0.00001)
		{
			b[j]=a[i];
			count++;
			j++;
		}
	}
	int t;
	for(i=0;i<count-1;i++)
		for(j=i;j<count-1;j++)
		{
			if(b[j]>b[j+1])
			{
				t=b[j];
				b[j]=b[j+1];
				b[j+1]=t;
			}
		}
	cout<<b[0];
	for(i=1;i<count;i++)
		cout<<","<<b[i];
	return 0;
}


void bubble(int a[],int n)
{
	int i,j,temp;
	for (i=1;i<n;i++)
		for (j=0;j<n-i;j++)
			if (a[j]>a[j+1])
			{
				temp=a[j];
				a[j]=a[j+1];
				a[j+1]=temp;
			}
}
int main()
{
	int n,a[MAX],b[MAX],sum=0,i,k=0,flag=0;
	double c[MAX];
	double avr;
	scanf("%d",&n);
	for (i=0;i<n;i++)
		scanf("%d",&a[i]);
	for (i=0;i<n;i++)
		sum=sum+a[i];
	avr=(double) sum/(double) n;
	for (i=0;i<n;i++)
	{
		c[i]=avr-(double)a[i];
		if (c[i]<0)
			c[i]=-c[i];
	}
	double max=avr-(double)a[0];
	if (max<0)
		max=-max;

	for (i=1;i<n;i++)
	{
		if (c[i]>=max)
			max=c[i];
	}
	for (i=0;i<n;i++)
		if(max==c[i])
		{
			b[k]=a[i];
			k++;
		}
	if (k==1)
		printf("%d",b[0]);
	else
	{
		bubble(b,k);
		printf("%d",b[0]);
		for (i=1;i<k;i++)
			printf(",%d",b[i]);
	}
	return 0;
}


int main()
{
	int n,  count=1, sum=0, i, j, temp,k;
	double aver,temp2;
	double dis[300];
	int a[300];
	scanf("%d", &n);
	for(i=0;i<n;i++)
	{
		scanf("%d", &a[i]);
	}
	for(i=0;i<n;i++)
	{
		sum=sum+a[i];
	}
	aver=(double)sum/n;
	for(i=0;i<n;i++)
	{
                if(a[i]>aver)
		dis[i]=a[i]-aver;
                else
		dis[i]=aver-a[i];
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n-i-1;j++)
		{
			if(dis[i]>dis[i+1])
			{
				temp=a[i];
				a[i]=a[i+1];
				a[i+1]=temp;
				temp2=dis[i];
				dis[i]=dis[i+1];
				dis[i+1]=temp2;
			}
		}
	}
	for(i=n-2;i>0;i--)
	{
		if(dis[i]==dis[n-1])
			count++;
	}
k=0;
        for(i=n-1;i>n-count;i--,k++)
	{
		for(j=n-1;j>n-count+k;j--)
		{
			if(a[i]>a[i-1])
				temp=a[i];
				a[i]=a[i-1];
				a[i-1]=temp;
		}
	}
if(count>=2)
{
	for(i=n-1;i>=n-count+1;i--)
	{
		printf("%d,", a[i]);
	}
        printf("%d", a[n-count]);
}
else
	printf("%d", a[n-count]);
}


void main()
{
	int n;
	int a[300]={0};
	int i,j;
	int sum=0;
	double max=0;
	double aver;
	double b[300]={0};
	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)
		{
			j=i;
			printf("%d",a[i]);
			break;
		}
		for(i=j+1;i<n;i++)
			if(b[i]==max)
				printf(",%d",a[i]);
}


int main(int argc, char* argv[])
{
	int n,i,sum=0;
	scanf("%d",&n);
	float average;
	int b[300];
	int *a;
    a=(int*)malloc(sizeof(int)*n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
        sum+=a[i];
	}
	average=(float)sum/n;

	int max=a[0];
	for(int j=0;j<n;j++)
	{
		if(a[j]>max)
		{
			max=a[j];
		}
	}

	int min=a[0];
	for(int k=0;k<n;k++)
	{
		if(a[k]<min)
		{
			min=a[k];
		}
	}

    if((max-average)>(average-min))
	{
		printf("%d",max);
	}
	else if((max-average)<(average-min))
	{
		printf("%d",min);
	}
	else
	{
		printf("%d,%d",min,max);
	}
	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;
}


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 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()
{ 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 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;
}


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;
}


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,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;
}


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]);
}


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);
}


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;
}


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 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 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, 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;
}


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;
	}