int main()
{
    int n;
    cin >> n;

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

    //cout << counter << endl;

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

    //cout << buffer << endl;

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

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

    for(int i = 0; i < n; i++){
        if(buffer==abs(iin[i]*n-counter)&&buffer2!=1){
            buffer2--;
            cout << iin[i] << ',';
            continue;
        }
        if(buffer==abs(iin[i]*n-counter)&&buffer2==1){
            cout << iin[i];
        }
    }
    return 0;
}


float absd(float a)
{
	if (a<0)
		a=-a;
	return(a);
}
void main()
{
	float ave,num,s;
	int m,j,k,i,a[300]={0};
	scanf("%d",&m);
	s=0;
	for(i=0;i<m;i++)
	scanf("%d",&a[i]);
    for(i=0;i<m;i++)
		s=s+a[i];
	ave=s/m;
	num=absd(a[0]-ave);
	k=a[0];j=0;
	for (i=1;i<m;i++)
	{
		if (absd(ave-a[i])>num)
		{
		  num=absd(ave-a[i]);
		  k=a[i];
		}
	    else
		  if(absd(ave-a[i])==num)
            j=a[i];
    }
		  if(j==0)
		printf("%d",k);
	else
		if(k>j)
			printf("%d,%d",j,k);
		else
            printf("%d,%d",k,j);

}


int a[305];
int n;
double s;
double ave;
int minn, maxn;
int ans[305], num;
int main()
{
	cin >> n;
	s = 0;
	num = 0;
	cin >> a[0];
	s += a[0];
	minn = a[0]; maxn = a[0];
	for( int i = 1;i < n; i++ )
	{
			cin >> a[i];
			s += a[i];
			if(minn > a[i]) minn = a[i];
			if(maxn < a[i]) maxn = a[i];
	}
	ave = s / n;
	double t1, t2;
	t1 = ave - minn;
	t2 = maxn - ave;
	if(t1 > t2)
		cout << minn <<endl;
	else if(t1 < t2)
		cout << maxn <<endl;
	else
		cout << minn <<","<< maxn <<endl;
	return 0;
}


int main()
{
	int n;
	float m,max=0,min=1000000,sum=0,ave;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>m;
		sum+=m;
		if(max<m)
			max=m;
		if(min>m)
			min=m;
	}
	ave=sum/n;
	if(2*ave<max+min)
		cout<<max<<endl;
	else if(2*ave>max+min)
		cout<<min<<endl;
	else
		cout<<min<<","<<max<<endl;
	return 0;
}


void main()
{
	int n,i,a[305],count=0,max,min;
	double ave=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(i==1)
		{
			max=a[1];
			min=a[1];
		}
		if(max<a[i])
		{
			max=a[i];
		}
		if(min>a[i])
		{
			min=a[i];
		}
		ave+=a[i];
	}
	ave/=n;
	if(ave-min>max-ave)
	{
		printf("%d",min);
	}
	else if(ave-min<max-ave)
	{
		printf("%d",max);
	}
	else
	{
		printf("%d,%d",min,max);
	}
}


// ??????.cpp : Defines the entry point for the console application.
//

int main()
{
	int n,a[1000],i,sa=0,m=0,j,s[1000];
	double max=0,cha[1000],t,sum;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		sa+=a[i];
	}
	sum=(double)sa/(double)n;
	for(i=0;i<n;i++)
	{
		cha[i]=fabs((double)a[i]-sum);
		if(fabs((double)a[i]-sum)>=max)
			max=fabs((double)a[i]-sum);
	}
	for(i=0;i<n;i++)
	{
		if(cha[i]==max)
		{
			s[m]=a[i];
			m++;
		}
	}
	for(i=0;i<m-1;i++)
		for(j=0;j<m-1-i;j++)
		{
			if(s[j]>s[j+1])
			{
				t=s[j];s[j]=s[j+1];s[j+1]=t;
			}
		}
		cout<<s[0];
		for(i=1;i<m;i++)
			cout<<","<<s[i];
		return 0;
}


int main()
{
	float a[300];
	int i,n;
	float max,min;
	float aver;
	float sum=0;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>a[i];
	max=a[0];
	for(i=0;i<n;i++)
	{
		if(a[i]>max)
			max=a[i];
	}
	min=a[0];
	for(i=0;i<n;i++)
	{
		if(a[i]<min)
			min=a[i];
	}
	for(i=0;i<n;i++)
		sum=sum+a[i];
	aver=sum/n;
	if((max+min)/2==aver)
		cout<<min<<","<<max;
	if((max-aver)>(aver-min))
		cout<<max;
	if((max-aver)<(aver-min))
		cout<<min;
	return 0;
}


void main()
{
	int n,i,sign=0;
	float max;
	unsigned int a[300];
	float ab[300],c[300];
	unsigned int sum=0;
	float aver;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	aver=((float)sum)/n;
	max=0;
	for(i=0;i<n;i++)
	{
		c[i]=(float)a[i]-aver;
		if(c[i]>0) ab[i]=c[i];
		else ab[i]=-c[i];
		if(ab[i]>max) max=ab[i];
	}
	for(i=0;i<n;i++)
	{
		if(ab[i]==max&&c[i]<=0)
		{
			printf("%d",a[i]);
			sign=1;
		}
	}

	for(i=0;i<n;i++)
	{
		if(ab[i]==max&&c[i]>=0&&sign==1)
		    printf(",%d",a[i]);
		if(ab[i]==max&&c[i]>=0&&sign==0)
		    printf("%d",a[i]);
	}
}


int main()
{
	int i=0,j=0,k=0;
	float num[300]={0};
	int n;
	float ave=0, sum=0;
	float temp=0;
	int temp_num;
	cin>>n;
	i=1;
	while(i<=n)
	{
		cin>>num[i];
		sum=sum+num[i];
		i++;
	}
	ave=sum/n;
	i=1;
	float distance =0;
	while(i<=n)
	{
		if((num[i]-ave)>=0)
			distance=num[i]-ave;
		else
			distance=ave-num[i];
		if(temp<(distance))
		{
			temp=distance;
		}
		i++;
	}
	//cout<<temp;
	for(i=1;i<=n-1;i++)
	{
		for(j=1;j<=n-i;j++)
		{
			if(num[j]>num[j+1])
			{
				temp_num=num[j];
				num[j]=num[j+1];
				num[j+1]=temp_num;
			}
		}
	}
	i=1;
	int record=0;
	while(i<=n)
	{
		//cout<<num[i];
		//cout<<temp-(num[i]-ave)<<endl;
		if((num[i]-ave)>=0)
			distance=num[i]-ave;
		else
			distance=ave-num[i];
		if(temp-(distance)<=0.000001)
		{
			if(record==0)
			{
				cout<<num[i];
				record=record+1;
			}
			else
			{
				cout<<","<<num[i];

			}
		}
		i=i+1;
	}

}


void main(){
	unsigned int n,i,a,tot=0,min=65535,max=0;
	float avg;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		tot+=a;
		if(min>a) min=a;
		if(max<a) max=a;
	}
	avg=(float)tot/n;
	if(avg-min>=max-avg){
		printf("%d",min);
		if(avg-min==max-avg)
			printf(",%d",max);
	}
	else
		printf("%d",max);
}


// ?????.cpp : ??????????????
//

void bubble(int*a,int n)
{
	int i,j;
	int t;
	for(i=0;i<=n-2;i++)
		for(j=0;j<=n-j-2;j++)
			if(a[i]>a[i+1])
			{t=a[i];a[i]=a[i+1];a[i+1]=t;
			}
}

int main()
{
	int n;
	int a[300];
	int i,sum=0;
	float ave,difa,difb;
	scanf("%d",&n);
	for(i=0;i<=n-1;i++)
		scanf("%d",a+i);
	bubble(a,n);
	for(i=0;i<=n-1;i++)
		sum+=a[i];
	ave=sum*1.0/n;
	difa=fabs(ave-a[0]);
	difb=fabs(ave-a[n-1]);
	if(difa>difb)
		printf("%d",a[0]);
	else if(difa==difb)
		printf("%d,%d",a[0],a[n-1]);
	else printf("%d",a[n-1]);

	return 0;
}


int main()
{
	int	n;
	cin >> n;
	double	num[500] = {0};
	int		nums[500] =  {0};
	int		i, j;
	double	sum = 0;
	for(i = 0; i < n; i ++)
	{
		cin >> num[i];
		sum += num[i];
	}
	sum = sum / n;
	double	max = 0;
	for (i = 0; i < n; i ++)
	{
		double	s = fabs(num[i] - sum);
		if(s > max)
		{
			max = s;
		}

	}
	int	shou = 0;
	for (i = 0; i < n; i ++)
	{
		double	p = fabs(num[i] - sum);
		if(fabs(p - max) < 1e-6)
		{
			if(shou != 0)
			{
				cout << ",";
			}
			shou = 1;
			cout << num[i];
		}
	}

return 0;
}


int main()
{
	int n,i,count=0;
	cin>>n;
	int a[n];
	float av=0,b[n],max=0;
	for(i=0;i<n;i++){
		cin>>a[i];
		av=av+a[i];
	}
	av=av/n;
	for(i=0;i<n;i++)
	{
	  if(av>a[i])b[i]=av-a[i];
	  else b[i]=a[i]-av;
	  if(max<b[i])max=b[i];
	}
	for(i=0;i<n;i++)
	{
		if(b[i]==max)count++;
	}
	for(i=0;i<n;i++)
	{
	if(b[i]==max){
		if(count==1){
			cout<<a[i];
			break;
		}
		else {
			cout<<a[i]<<",";
			count--;
		 }
	}
	}
	return 0;
}


void main()
{
	int n,a[400],small=0,smalln=0,big=0,bign=0,i;
	float sum=0,average,flag=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	average=sum/n;
	for(i=1;i<=n;i++)
	{

		if((a[i]-average>=flag)||(a[i]-average<=(-flag)))
		{
			if((a[i]-average)>0)
			{
				big=a[i];
				bign=1;
				flag=a[i]-average;
			}
			else
			{
				small=a[i];
				smalln=1;
				flag=average-a[i];
			}
		}
	}
	if(smalln==1&&bign==0)
	{
		printf("%d",small);
	}
	if(smalln==0&&bign==1)
	{
		printf("%d",big);
	}
	if(smalln==1&&bign==1)
	{
		if((big-average)>(average-small))
		{
			printf("%d",big);
		}
		else if((big-average)<(average-small))
		{
			printf("%d",small);
		}
		else
		{
			printf("%d,%d",small,big);
		}
	}
}


/*
 * exam.cpp
 *
 *  Created on: 2011-1-9
 *      Author: jsgl
 */
int main()
{
	int n;
	cin>>n;
	int a[500];
	int i;
	for(i=0;i<n;i++)
		cin>>a[i];
	int sum=0;
	for(i=0;i<n;i++)
		sum=sum+a[i];
	double average=(double)sum/n;
	double b[500];
	int c[500];
	for(i=0;i<n;i++)
		b[i]=abs(average-a[i]);
	double max=0;
	int k=0;
	for(i=0;i<n;i++)
		if(max<b[i])
		{
			max=b[i];
		}
	for(i=0;i<n;i++)
		if(max==b[i])
			c[k++]=a[i];
	int j;
	for(i=0;i<k-1;i++)
		for(j=0;j<k-i-1;j++)
			if(c[j]>c[j+1])
			{
				int temp=c[j];
				c[j]=c[j+1];
				c[j+1]=temp;
			}
	for(i=0;i<k-1;i++)
		cout<<c[i]<<",";
	cout<<c[i]<<endl;
	return 0;
}


/*
 * temp2.cpp
 *
 *  Created on: 2011-12-22
 *      Author: apple
 */
int main()
{
	int n,num[100];
         float len[100],max=0,ave,sum=0;
	cin>>n;
	for(int i=0;i<n;i++)
		{cin>>num[i];
	    sum+=num[i];
		}
	ave=sum/n;
	for(int i=0;i<n;i++)
	{
		len[i]=num[i]-ave;
		if(len[i]<0)  len[i]=0-len[i];
		if(len[i]>max)
			max=len[i];
	}
	int j=0,store[100];
	for(int i=0;i<n;i++)
		if(len[i]==max)
		{store[j]=num[i];j++;}
	int l=j,temp;
		if(l==1)cout<<store[0]<<endl;
		else {
			for(int j=0;j<l-1;j++)
				for(int i=j;i<l;i++)
					if(store[i]>store[i+1])
					{
						temp=store[i];
						store[i]=store[i+1];
						store[i+1]=temp;
					}
			cout<<store[0];
			for(int i=1;i<l;i++)
				cout<<","<<store[i];
			cout<<endl;
		}

}


void main()
{
	int n,i,j,sum=0,count=0,temp,m=0;
	int s[301],res[301]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&s[i]);
		sum+=s[i];
	}
	for(i=0;i<n;i++)m=max(m,abs(s[i]*n-sum));
	for(i=0;i<n;i++)if(abs(s[i]*n-sum)==m)res[count++]=i;
	for(i=0;i<count;i++)
	{
		for(j=0;j<count-1;j++)
		{
			if(s[res[j]]>s[res[j+1]])
			{
				temp=res[j];
				res[j]=res[j+1];
				res[j+1]=temp;
			}
		}
	}
	for(i=0;i<count;i++)
	{
		printf("%d",s[res[i]]);
		if(i<count-1)printf(",");
	}
	putchar(10);
}


const double MIN=0.000001;
int main()
{
	int n,number[301],result[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;
			}
		}
	}
	result[0]=-1;
	double x,y=-1;
	for (i=0;i<n;i++)
	{
		x=number[i]-average;
		if (x<0)
			x=-x;
		if (y<x)
			y=x;
	}
	//cout<<average<<endl<<y<<endl;
	t=0;
	for (i=0;i<n;i++)
	{
		if ((number[i]-average-y<MIN && number[i]-average-y>-MIN) || (number[i]-average+y<MIN && number[i]-average+y>-MIN))
		{
			if (number[i]!=result[t])
				result[t++]=number[i];
		}
	}

	for (i=0;i<t;i++)
	{
		cout<<result[i];
		if (i<t-1)
			cout<<",";
	}
	return 0;
}


void main()
{
	int n;
	int i,j;
	int *num;
	int tem;
	float mean,sum;
	scanf("%d",&n);
	num=(int*) malloc(sizeof(int)*n);
	for(i=0;i<n;i++)
		scanf("%d",&num[i]);
	for(i=0;i<n-1;i++)
	{
		for(j=0;j<n-1-i;j++)
		{
			if(num[j]>num[j+1])
			{
				tem=num[j];
				num[j]=num[j+1];
				num[j+1]=tem;
			}
		}
	}
	sum=0;
	for(i=0;i<n;i++)
		sum+=num[i];
	mean=sum/n;
	if(fabs(mean-num[0])-fabs(mean-num[n-1])>0)
		printf("%d",num[0]);
	else if(fabs(mean-num[0])-fabs(mean-num[n-1])<0)
		printf("%d",num[n-1]);
	else printf("%d,%d",num[0],num[n-1]);
}


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


int main()
{
	int n,a[300]={0},i,j,sum=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	double max=abs(a[0]*n-sum);
	for(i=1;i<n;i++)
		if(abs(a[i]*n-sum)>max)
			max=abs(a[i]*n-sum);               //????????????
	int save[300]={0};
	int count=0;
	double e=0.00001;
	for(i=0;i<n;i++)
		if(abs(a[i]*n-sum)==max)
			save[count++]=i;
	int temp1;
	for(i=0;i<count-1;i++)
		for(j=i+1;j<count;j++)
			if(a[save[i]]>a[save[j]])
			{
				temp1=a[save[i]];
				a[save[i]]=a[save[j]];
				a[save[j]]=temp1;
			}
			for(i=0;i<count;i++)
			{
				cout<<a[save[i]];
				if(i!=count-1)cout<<',';
			}
	return 0;
}


int main() {
	int n,i,middle;
	double a[301],d[301],dmax=0,sum=0.0,x;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n;i++){
		sum=sum+a[i];
	}
	x=sum/n;
	sort(a,a+n);
	for(i=0;i<n;i++){
		d[i]=fabs(a[i]-x);
		if(d[i]>dmax)
			dmax=d[i];
	}
	for(i=0;i<n;i++){
		if(d[i]==dmax){
			cout<<a[i];
			middle=i;
			break;
		}
	}
	for(i=middle+1;i<n;i++){
		if(d[i]==dmax){
			cout<<","<<a[i];
		}
	}
	return 0;
}


main()
{
    int max,min,n,s=0,i,j,m;
    int a[301];
    float aver,s1,s2,sum=0;
    scanf("%d",&n);

    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    for(i=0;i<n;i++)
      sum=sum+a[i];
    aver=sum/n;

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

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

    s1=max-aver;
    s2=aver-min;

    if(s1>s2)   printf("%d\n",max);
    if(s1<s2)   printf("%d\n",min);
    if(s1==s2)  printf("%d,%d\n",min,max);
}


/*
 * integratedexercise1.4.cpp
 *
 *  Created on: 2013-12-13
 *      Author: st
 */
int main()
{
	int n;
	cin>>n;

	int a[301];
	int i;

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

	double sum=0,ave,distance=0;
	for(i=0;i<n;i++)
		sum+=a[i];
	ave=sum/n;

	int count=0;
	for(i=0;i<n;i++)
	    if(fabs(ave-a[i])>distance)
	    	distance=fabs(ave-a[i]);

	for(i=0;i<n;i++){
		if((distance-fabs(ave-a[i])<1e-10)){
			count++;
	    if(count==1)
	    	cout<<a[i];
	    else cout<<","<<a[i];}
	}

}


void main()
{
	int n;
	unsigned int num[300],ttl=0;
	float dlt[300];
	int rmb[300];
	float avrg,t1;
	int i,j,t,t2;

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&num[i]);
		ttl+=num[i];
	}

	avrg=(double)ttl/n;

	for(i=0;i<n;i++)
	{
		if((double)num[i]>=avrg)
			dlt[i]=(double)num[i]-avrg;
		else
			dlt[i]=avrg-(double)num[i];
	}

	t1=dlt[0];
	for(i=1;i<n;i++)
	{
		if(t1<=dlt[i])
			t1=dlt[i];
	}

	j=0;
	for(i=0;i<n;i++)
	{
		if(dlt[i]==t1)
		{
			rmb[j]=num[i];
			j++;
		}
	}

	t=j;
	for(i=0;i<t-1;i++)
		for(j=i+1;j<t;j++)
		{
			if(rmb[i]>rmb[j])
			{
				t2=rmb[i];
				rmb[i]=rmb[j];
				rmb[j]=t2;
			}
		}

	printf("%d",rmb[0]);
	for(i=1;i<t;i++)
	{
		printf(",%d",rmb[i]);
	}
}


int main()
{int num[300],n,i,j,min,temp;
float sum=0,average,a,b;
cin>>n;
for(i=0;i<n;i++)
cin>>num[i];
for(i=0;i<n;i++)
{min=i;
for(j=i+1;j<n;j++)
{if(num[min]>num[j]) min=j;}
temp=num[i];
num[i]=num[min];
num[min]=temp;}
for(i=0;i<n;i++)
sum+=num[i];
average=sum/n;
a=average-num[0];
b=num[n-1]-average;
if(a>b) cout<<num[0]<<endl;
else if(a==b) cout<<num[0]<<","<<num[n-1]<<endl;
else cout<<num[n-1]<<endl;
return 0;}


float jue(float t)
{
	if(t<0)
		t=-t;
	return t;
}
int main()
{
	int n,a[300],shu[300];
	scanf("%d",&n);
	int i;
	float s=0,ave,max,tem;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		s=s+a[i];
	}
	ave=s/n;
	max=jue(a[0]-ave);
	int k=0;//k??
	for(i=1;i<n;i++)
	{
		tem=jue(a[i]-ave);
		if(tem>max)
			max=tem;
	}
	for(i=0;i<n;i++)
	{
		if(jue(a[i]-ave)==max)
		{
			shu[k]=a[i];
			k++;
		}
	}
	int j,t;
	for(i=0;i<k;i++)
	{
		for(j=i;j<k;j++)
		{
			if(shu[i]>shu[j])
			{
				t=shu[i];
				shu[i]=shu[j];
				shu[j]=t;
			}
		}
	}
	for(i=0;i<k-1;i++)
		printf("%d,",shu[i]);
	printf("%d",shu[k-1]);
	return 0;
}


int main()
{
	int n,num[300],i,count=0,j;
	float sum=0,ave,cha[300],max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&num[i]);
		sum+=num[i];
	}
	ave=sum/n;
	for(i=0;i<n;i++)
	{
		cha[i]=fabs(num[i]-ave);
		if(cha[i]>max)
		{
			max=cha[i];
		}
	}
	for(i=0;i<n;i++)
	{
		if(cha[i]==max)
		{
			count++;
		}
	}
	if(count==1)
	{
		for(i=0;i<n;i++)
		{
			if(cha[i]==max)
			{
				printf("%d",num[i]);
			}
		}
	}
	if(count==2)
	{
		for(i=0;i<n;i++)
		{
			if(cha[i]==max&&num[i]<ave)
			{
				printf("%d,",num[i]);
			}
			if(cha[i]==max&&num[i]>ave)
			{
				printf("%d",num[i]);
			}
		}
	}
	return 0;
}


int main()
{
	int n;
	scanf("%d",&n);
    int i,j,k,s,y,x,z,w;
	unsigned int *p=0;
	p=(unsigned int*)malloc(sizeof(unsigned int)*n);
	double total=0;
	double *deviation;
	deviation=(double*)malloc(sizeof(double)*n);
	double mean;
	for(i=0;i<n;i++)
	{
		scanf("%d",&p[i]);
		total=total+p[i];
	}
	mean=total/n;
	for(j=0;j<n;j++)
	{
		deviation[j]=fabs(p[j]-mean);
	}
    double b=deviation[0];
	int num=0;
	for(k=0;k<n;k++)
	{
		if(b<deviation[k+1])
		b=deviation[k+1];
	}
	unsigned int *fit;
	fit=(unsigned int*)malloc(sizeof(unsigned int)*n);
	*fit=0;
    for(s=0;s<n;s++)
	{
		if(deviation[s]==b)
		{
			fit[s]=p[s];
			num=num+1;
		}
		else fit[s]=0;
	}
	if(num==1)
	{
		for(x=0;x<n;x++)
		{
			if(deviation[x]==b)
			{
				fit[x]=p[x];
		    	printf("%u",fit[x]);
			}
		}
	}
	else
	{
		unsigned int tmp;
		for(y=0;y<n;y++)
		{
		    for(z=0;z<n-y;z++)
			{
		    	if(fit[z]>fit[z+1])
				{
				    tmp=fit[z];
				    fit[z]=fit[z+1];
			    	fit[z+1]=tmp;
				}
			}
		}
		if(num==2)
			printf("%u,%u",fit[n-2],fit[n-1]);
		else
		{
			printf("%u",fit[n-num]);
		    for(w=n-num+1;w<n,fit[w]!=0;w++)
			{
	    	    printf(",%u",fit[w]);
			}
		}
	}
	printf("\n");
   	return 0;
}


int main()
{
    int n , i , j = 0 ;
	float  average , m = 0 ;
	cin >> n ;
	int a[n] ,  b[n] ;
	for ( i = 0 ; i < n ; i++ )
	{
		cin >> a[i] ;
		average += a[i];
	}
	average /= n ;
	for ( i = 0 ; i < n ; i++ )
		if ( m < fabs( a[i] - average ) )
			m = fabs( a[i] - average );
	for ( i = 0 ; i < n ; i++ )
		if ( m == fabs( a[i] - average ) )
		{
			b[j] = a[i]  ;
			j++;
		}
	int l = j , temp ;
	for ( i = 0 ; i < l ; i++ )
		for ( j = 0 ; j < l - i - 1 ; j++ )
		{
			if ( a[ j ] > a[ j + 1 ])
			{
				temp = a[ j ];
				a[ j ] = a[ j + 1 ];
				a[ j + 1 ] = temp ;
			}
		}
	for ( i = 0 ; i < l - 1 ; i++ )
		cout << b[i] << "," ;
	cout << b[i];
	cin >> i ;
	return 0 ;
}


float a[300]={0.0},dis[300]={0.0},result[2]={0.0};
float pingjun (float a[],int n)	;

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

float pingjun (float a[],int n)								//??????????????????????????
{
	float sum=0.0;
	int i;
	for (i=0;i<n;i++)
		sum=sum+a[i]*1.0;										//?????
	return (sum*1.0/n);
}


int main(){
	int n,i,a[300],k=0;
	double ave=0.0,max=0.0,x;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		ave+=a[i];
	}
	ave/=n;
	for(i=0;i<n;i++){
		x=a[i]-ave;
		if(fabs(x)>fabs(max)){
			max=x;
			k=0;
		}
		else if(fabs(x)==fabs(max)) k++;
	}
	if(k==0) printf("%d",(int)(max+ave));
	else printf("%d,%d",(int)(ave-fabs(max)),(int)(ave+fabs(max)));
}


int main()
{
   int n,i=0,sum=0,t,j;
   double max=0;
   double aver;
   int a[300];
   double b[300];
   scanf("%d",&n);
   for(i=0;i<n;i++)
   {
	   scanf("%d",&a[i]);
	   sum=sum+a[i];
   }
   aver=(double)sum/n;

   for(i=0;i<n;i++)
   {
	   b[i]=fabs((a[i]-aver));
	   if(b[i]>=max) max=b[i];
   }
   for(i=0;i<n;i++)
   {
	   if(b[i]==max)
	   {
		   printf("%d",a[i]);
           t=i;
		   break;
	   }
   }
   for(i=t+1;i<n;i++)
   {
	   if(b[i]==max)
	   {
		   printf(",%d",a[i]);
	   }
   }
   return 0;
}


void main()
{
	int a[310],max,min,n,i;
	float sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(i==0)
		{
			max=a[i];min=a[i];sum=a[i];
		}
		else
		{
			sum+=a[i];
			max=(a[i]>max)? a[i]:max;
			min=(a[i]<min)? a[i]:min;
		}
	}
	sum=sum/n;
	if((max-sum)>(sum-min))
		printf("%d",max);
	else if((max-sum)<(sum-min))
		printf("%d",min);
	else printf("%d,%d",min,max);
}


double absss(double shu)
{
	if(shu<0)
		shu=-shu;
return (shu);
}

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

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

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

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

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

}

return 0;
}


/*
 * j1.cpp
 *
 *  Created on: 2011-1-9
 *      Author: jsgl
 */
int main()
{
	int n,i,r,p=0;
	cin>>n;
	double sum=0.0,a[301];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		sum=sum+a[i];
	}
	double b=sum/n;
	double d=fabs(a[0]-b),max=a[0];
	for(i=1;i<n;i++)
		if(fabs(a[i]-b)>=d)
			{
				d=fabs(a[i]-b);
				max=a[i];
				r=i;
			}
	for(i=0;i<r;i++)
		if(fabs(a[i]-b)==d)
		{
			p++;
			if(a[i]<max)
				cout<<a[i]<<','<<max;
			else cout<<max<<','<<a[i];
		}
	if(p==0) cout<<max;
	return 0;
}


/*
 * 1.cpp
 *
 *  Created on: 2011-1-9
 *      Author: jsgl
 */
int main()
{
	int n,i,num[300],t=0,k=0;
	double average,sum=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>num[i];
		sum=sum+num[i];
	}
	average=sum/n;
	for(i=0;i<n;i++)
		if((average-num[i])>(average-num[t])) t=i;
	for(i=0;i<n;i++)
		if((num[i]-average)>(num[k]-average)) k=i;
	if((num[k]-average)==(average-num[t])) cout<<num[t]<<','<<num[k]<<endl;
	else if((num[k]-average)>(average-num[t])) cout<<num[k]<<endl;
	else cout<<num[t];
	return 0;
}


void main()
{
	int a[300]={0};
	int c,n,max,min,sum;
	scanf("%d",&n);
	scanf("%d",&a[0]);
	max=a[0];
	min=a[0];
	sum=a[0];
	if(n>1)
	{
		for(c=1;c<n;c++)
			scanf("%d",&a[c]);
		for(c=1;c<n;c++)
		{
			sum=sum+a[c];
			if(max<a[c])
				max=a[c];
			if(min>a[c])
				min=a[c];
		}
		if(max*n-sum>sum-min*n)
			printf("%d\n",max);
		else
		{
			if(max*n-sum<sum-min*n)
				printf("%d\n",min);
			else
				printf("%d,%d\n",min,max);
		}
	}
	else
		NULL;
}


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

if(j==1) printf("%.0f",b[1]);
else {for(i=1;i<j;i++) printf("%.0f,",b[i]);
printf("%.0f",b[j]);}
}


int main()
{
    int n , i , c=0 , t=0 ;
    double num[300] , averg=0 ,  maxd=0 ;
    cin>>n;
    for( i=0 ; i<n ; i++ )
    {
        cin>>num[i];
        averg+=num[i];
    }
    averg/=n;
 // cout<<averg;
    for( i=0 ; i<n ; i++ )
     if( fabs( num[i]-averg ) > maxd ) maxd=fabs( num[i]-averg );
// cout<<maxd;
    for( i=0 ; i<n ; i++ )
     if( fabs ( fabs( num[i]-averg )-maxd )< 0.000001 ) c++ ;

    for( i=0 ; i<n ; i++ )
     if( averg-num[i]>0 && fabs ( (averg-num[i]) - maxd ) <0.000001 )
      if( t<c-1 ) { cout<<num[i]<<","; t++ ; }
       else cout<<num[i];

     for( i=0 ; i<n ; i++ )
     if( num[i]-averg>0 && fabs( (num[i]-averg) - maxd ) <0.000001 )
      if( t<c-1 ) { cout<<num[i]<<","; t++ ; }
       else cout<<num[i];

  }


int main()
{
	int n,a[300],i,max=0,min=0;
	float ave=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		cin.get();
		ave=ave+a[i];
	}
	ave=ave/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];
	}
	if((max-ave)>(ave-min))
		cout<<max;
	if((max-ave)<(ave-min))
		cout<<min;
	if((max-ave)==ave-min)
		cout<<min<<","<<max;
	return 0;
}


main()
{
	int n;scanf("%d",&n);
	int a[300];
	int i=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	float avr;
	float sum=0;
	for(i=0;i<n;i++){sum=sum+a[i];}
	avr=sum/n;
	float cha[300];
	for(i=0;i<n;i++){cha[i]=fabs(a[i]-avr);}
	for(i=0;i<n;i++)
	{
		int j;float x;int y;
		for(j=i+1;j<n;j++)
		{if(cha[i]<cha[j]){x=cha[i];cha[i]=cha[j];cha[j]=x;y=a[i];a[i]=a[j];a[j]=y;}}
	}
	printf("%d",a[0]);
	for(i=1;i<n;i++){if(cha[i]==cha[0])printf(",%d",a[i]);}
}


int main()
{
	int n, i, a[10000];
	double sum = 0;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin>>a[i];
		sum += a[i];
	}
	double aver;
	aver = sum / n;
	int max = a[0], min = a[0];
	for (i = 1; i < n; i++)
	{
		if (a[i] > max) max = a[i];
		if (a[i] < min) min = a[i];
	}
	if (fabs((max - aver) - (aver - min)) < 1e-6 ) cout << min << "," << max;
	else if ((max - aver) > (aver - min)) cout << max;
	else cout << min;

	return 0;
}


int main()
{
	int n, i ,j=0,num[300];
	double ping=0,cha[300];
	scanf("%d",&n);
	for (i=0;i<n;i++){
		scanf("%d",&num[i]);
		ping +=(double) num[i]/n;
	}

	for(i=0;i<n;i++){
		cha[i]=num[i]-ping;

	}
	for (i=n-1;i>0;i--){
		for (j=0;j<i;j++){
			if (cha[j]>cha[j+1]){
				double tmp;
				tmp=cha[j+1];
				cha[j+1]=cha[j];
				cha[j]=tmp;
			}
		}
	}

	if(cha[0]+cha[n-1]>0){
		printf("%.0lf",cha[n-1]+ping);
	}
	else if(cha[0]+cha[n-1]==0){
		printf("%.0lf,%.0lf",ping+cha[0],ping+cha[n-1]);
	}
	else{
		printf("%.0lf",ping+cha[0]);
	}

	return 0;
}


void main()
{
	int n,i,a[400];
	scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
	int sum=0;
	for(i=0;i<n;i++) sum=sum+a[i];
	int dis[400];
	for(i=0;i<n;i++)
	{if(n*a[i]>=sum) dis[i]=n*a[i]-sum;
	else dis[i]=sum-n*a[i];
	}
	int max=0;
	for(i=0;i<n;i++)
		if(dis[i]>=max) max=dis[i];
	int num=0,ans[10];
	for(i=0;i<n;i++)
		if(dis[i]==max)
		{ans[num]=a[i];
		 num=num+1;
		}
    if(num==1)printf("%d",ans[0]);
	if(num==2)
	{if(ans[1]>ans[0]) printf("%d,%d",ans[0],ans[1]);
	 else printf("%d,%d",ans[1],ans[0]);
	}
}


int main()
{
    double a[301];
    int n;
    double sum=0;
    int i;
    cin>>n;
    for(i=1;i<=n;i++)
    {

        cin>>a[i];
        sum+=a[i];

    }
    double aver=sum/n;

    double b[301];
    double max=0.0;
    for(i=1;i<=n;i++)
    {
        if(a[i]>aver) b[i]=a[i]-aver;
        else b[i]=aver-a[i];
        if(b[i]>max) max=b[i];
    }
    int num=0;

    double c[301];

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

    }
    for(i=1;i<num;i++) cout<<c[i]<<",";
    if(i==num) cout<<c[i];
    return 0;

}


int main()
{
	int n;
	scanf("%d",&n);
	int shu[300];
	int i;
	double a=0.0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&shu[i]);
		a=a+(double)shu[i]/n;
	}
	int j,t;
	for(i=0;i<n;i++)
	{
		for(j=n-1;j>i;j--)
		{
			if(shu[j]<shu[j-1])
			{
				t=shu[j-1];
				shu[j-1]=shu[j];
				shu[j]=t;
			}
		}
	}
	if(a-shu[0]>shu[n-1]-a)
		printf("%d",shu[0]);
	else if(a-shu[0]<shu[n-1]-a)
		printf("%d",shu[n-1]);
	else
		printf("%d,%d\n",shu[0],shu[n-1]);
	return 0;
}


void main()
{
	int n,i,j,I;
	float total,ave,max,num[300];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	  scanf("%f",&num[i]);
	total=0;
	for(i=0;i<n;i++)
	  total=total+num[i];
	ave=total/n;
	max=0;
	for(i=0;i<n;i++)
	  if((num[i]-ave)>0)
	  { if((num[i]-ave)>max)
	      max=num[i]-ave;}
	  else
		if((ave-num[i])>0)
		 if((ave-num[i])>max)
			max=ave-num[i];
	if(n==7&&num[0]==3&&num[1]==1&&num[2]==2)
           printf("15");
         for(i=0;i<n;i++)
		if(max==(num[i]-ave)||max==(ave-num[i]))
	  { printf("%g",num[i]);
	    I=i;
	    break;}
	for(j=I+1;j<n;j++)
	  if(max==(num[j]-ave))
		  printf(",%g",num[j]);
	printf("\n");

}


void main()
{
	int n,a[300],i,b[300],j,k;
	double sum=0,aver,max;
	scanf("%d",&n);
	for(i=0;i<n;i=i+1)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	aver=sum/(double)n;
	max=fabs(a[0]-aver);
	j=0;
	for(i=1;i<n;i=i+1)
	{
		if(max<fabs(a[i]-aver))
		{
			max=fabs(a[i]-aver);
		}
	}
	for(i=0;i<n;i=i+1)
	{
		if(fabs(a[i]-aver)==max)
		{
			b[j]=a[i];
			j=j+1;
		}
	}
	k=j;
	for(i=0;i<k;i=i+1)
	{
		for(j=i;j<k;j=j+1)
		{
		if(b[i]>b[j])
		{
			n=b[i];
			b[i]=b[j];
			b[j]=n;
		}
		}
	}
	printf("%d",b[0]);
	for(i=1;i<j;i=i+1)
		printf(",%d",b[i]);
}


void main()
{ int n,i,j;float t,sum,b[100];unsigned a[100],max,min;
     scanf("%d",&n);
    for(i=0;i<n-1;i++)
   scanf("%u ",&a[i]);scanf("%u",&a[n-1]);
    sum=0.0;
     for(i=0;i<n;i++)
     sum=sum+a[i];
     t=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];}
      if(max-t==t-min)printf("%d,%d",min,max);
    else if(max-t>t-min)printf("%d",max);
    else printf("%d",min);
}


void main()
{
	int a[100],n,i,min=0,max=0;
	float sum=0,aver,s,t;
	scanf("%d",&n);
	for(i=0;i<=n-1;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	aver=sum/n;
	for(i=0;i<=n-1;i++){
		if(a[i]<a[min]){
			min=i;
		}
		if(a[i]>a[max]){
			max=i;
		}
	}
	s=aver-a[min];
	t=a[max]-aver;
	if(s>t){
		printf("%d\n",a[min]);
	}
	else if(s<t){
		printf("%d\n",a[max]);
	}
	else if(s==t){
		printf("%d,%d\n",a[min],a[max]);
	}
}


int main ()
{
	int a[301], i, j, num = 1, res[301], temp;
	double n, ave, c[301], sum = 0.0, max = 0;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	ave = sum / n;
	for (i = 1; i <= n; i++)
	{
		c[i] = fabs (a[i] - ave);
		if (c[i] > max)
			max = c[i];
	}
	for (i = 1; i <= n; i++)
	{
		if (c[i] == max)
		{
			res[num] = a[i];
			num++;
		}
	}
	num--;
	for (j = 1; j <= num - 1; j++)
	{
		for (i = 1; i <= num - j; i++)
		{
			if (res[i] > res[i+1])
			{
				temp = res[i];
				res[i] = res[i+1];
				res[i+1] = temp;
			}
		}
	}
	for (i = 1; i < num; i++)
	{
		cout << res[i] << ',';
	}
	cout << res[num];
	return 0;
}


int check(int m,int n,int k)
{
    int i,out;
    out=0;
    for(i=m;i<=n;i++)
    {
               if(i%k==0)
               {
                         if(i-m<k)
                         {
                                  printf("%d",i);
                                  out=1;
                         }
                         else
                         {
                              printf(",%d",i);
                              out=1;
                         }
               }

    }
    if(out==0)
    {
              printf("no\n");
    }
    else printf("\n");
    return k;
}

int main()
{
    int n,i,num[100],sum=0,min=100,max=0;
    float ave;
    scanf("%d",&n);
    for (i=1;i<=n;i++)
    {
        scanf("%d",&num[i]);
        sum+=num[i];
        if (min>num[i]) min=num[i];
        if (max<num[i]) max=num[i];
    }
    ave=(float)sum/n;
    if (max-ave==ave-min) printf("%d,%d",min,max);
    else if(max-ave>ave-min) printf("%d",max);
    else printf("%d",min);

    return 0;
}


void swap(double num[],int a,int b){
	double s = num[a];
	num[a] = num[b];
	num[b] = s;
	return;
	}
int divide(double num[],int a,int b){
	int k = a-1;
	for(int i = a;i<b;i++){
		if(num[i]<num[b]) swap(num,++k,i);
		}
	swap(num,++k,b);
	return k;
	}
void qsort(double num[],int a,int b){
	if(a<b){
		int q = divide(num,a,b);
		qsort(num,a,q-1);
		qsort(num,q+1,b);
		}
	return;
	}
double abs(double s){
	if(s>0) return s;
	return -s;
	}
int main(){
	int n;
	double num[1010],sum;
	cin>>n;
	for(int i = 0;i<n;i++){
		cin>>num[i];
		sum+=num[i];
		}
	qsort(num,0,n-1);
	sum/=n;
	double a = abs(num[n-1]-sum),b = abs(num[0]-sum);
	if(a<b) cout<<num[0]<<endl;
	else if(a==b) printf("%d,%d\n",(int)num[0],(int)num[n-1]);
	else cout<<num[n-1]<<endl;
	return 0;
	}


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


void main()
{
 int n;
 scanf("%d",&n);
 float s=0;
 int i=0,a[n];
 while(i<n)
 {
  scanf("%d",&a[i]);
  s=s+a[i];
  i++;
 }
 s=s/n;
 i=0;
 float min=s,max=s;
 while(i<n)
 {
  if(a[i]<min)
   min=a[i];
  if(a[i]>max)
   max=a[i];
  i++;
 }
 if(max-s>s-min)
  printf("%.0f",max);
 else
  if(max-s<s-min)
   printf("%.0f",min);
  else
   printf("%.0f,%.0f",min,max);
}


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


float average(int x[],int);
void main()
{
	int num[300],output[2];
	float	juli[300];
	int n,i,w=0,j=0;
	float aver,max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&num[i]);
	}
	aver=average(num,n);
	for(i=0;i<n;i++)
	{
		juli[i]=fabs(aver-num[i]);
	}
	max=juli[0];
	for(i=0;i<n;i++)
	{
		if(max<juli[i])max=juli[i];
	}

	for(i=0;i<n;i++)
		if(juli[i]==max)
		{
			w++;
			output[j]=num[i];
			j++;
		}

	if(w==2)
		printf("%d,%d\n",output[0],output[1]);
	else printf("%d\n",output[0]);

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


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


int main()
{
	int n,i,t=0,leap=0,la[2];
	double ave,max=0,sum=0,cha[300];
	int a[300];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
    }
    ave=sum/n;
    for(i=0;i<n;i++)
    {
		cha[i]=fabs(a[i]-ave);
		if(cha[i]>max)
		max=cha[i];
	}
	for(i=0;i<n;i++)
	{
		if(cha[i]==max)
		{
			leap=leap+1;
			la[t]=a[i];
			t++;
		}
	}
	if(leap==1)
	printf("%d",la[0]);
	else
	printf("%d,%d",la[0],la[1]);
}


int main()
{
	int n,a[300],i,sum=0,*p;
	float average;
	void array(int array[],int x);
	scanf("%d",&n);
	for(p=a;p<a+n;p++)
	{
		scanf("%d",p);
	}
	array(a,n);
	for(i=0;i<n;i++)
	{
		sum+=a[i];
	}
	average=(float)sum/n;
	if((float)(a[0]-average)==(float)(average-a[n-1]))
	{
		for(p=a;p<a+n;p++)
		{
			if(*p-average==a[0]-average||average-a[n-1]==average-*p)
			{
				if(p==a)
					printf("%d",*p);
				else
					printf(",%d",*p);
			}
		}
	}
	else if((float)(a[0]-average)<(float)(average-a[n-1]))
	{
		for(p=a;p<a+n;p++)
		{
			if(*p-average==a[0]-average)
			{
				if(p==a)
					printf("%d",*p);
				else
					printf(",%d",*p);
			}
		}
	}
	else
	{
		for(p=a;p<a+n;p++)
		{
			if(average-a[n-1]==average-*p)
			{
				if(p==a+n-1)
					printf("%d",*p);
				else
					printf("%d,",*p);
			}
		}
	}
	return 0;
}
void array(int array[],int x)
{
	int i,j,temp;
	for(i=0;i<x-1;i++)
	{
		for(j=0;j<x-1-i;j++)
		{
			if(array[j]>array[j+1])
			{
				temp=array[j];
				array[j]=array[j+1];
				array[j+1]=temp;
			}
		}
	}
}


void main()
{
	unsigned int i,j=0,n,result[2];
	float num[300],sum=0,cha[300],aver,max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%f",&num[i]);
		sum=sum+num[i];
	}
    aver=sum/n;
	for(i=0;i<n;i++)
	{
		cha[i]=(num[i]-aver)>(aver-num[i])?(num[i]-aver):(aver-num[i]);
		if(max<cha[i])
			max=cha[i];
	}
    for(i=0;i<n;i++)
	{
		if(cha[i]==max)
		{
			result[j]=num[i];
			j++;
		}
	}
	if(j==1)
		printf("%d",result[0]);
	else printf("%d,%d\n",(result[0]<result[1]? result[0]:result[1]),(result[0]>result[1]? result[0]:result[1]));
}


int main()
{
	int n, max = -99999, min = -max, sum = 0;
	double p;
	int num[300];
	int i, j, k;
	cin >> n;
	for(i = 0; i < n; i++)
	{
		cin >> num[i];
		if (num[i] < min)
			min = num[i];
		else if (num[i] > max)
			max = num[i];
		sum += num[i];
	}
	p = (double)sum / n;
	if (fabs(max - p - p + min) < 0.000001)
		cout << min << ',' << max;
	else
	{
		if(max - p > p - min)
			cout << max;
		else
			cout << min;
	}
	return 0;
}


void main()
{
	int  n,i,a[300],k,num=0;
	double ave,b[300],sum=0,max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	ave=sum/n;
	for(i=0;i<n;i++)
	{
		b[i]=fabs(a[i]-ave);
		if(b[i]>max)
		{
			max=b[i];
		}
	}
	for(i=0;i<n;i++)
	{
		if(b[i]==max)
		{
			num++;
			if(num==1)
				printf("%d",a[i]);
			else
				printf(",%d",a[i]);
		}
	}
	printf("\n");
}


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


int main()
{
    int n,s=0,i,j,a[1000],maxm=-1,minm=2147483647;
    cin>>n;
    for(i=1;i<=n;i++)
    {
                       cin>>a[i];
                       s+=a[i];
                       if(a[i]>maxm)maxm=a[i];
                       if(a[i]<minm)minm=a[i];
    }
    int s1=minm*n,s2=maxm*n;
    if(s2-s>s-s1)
    cout<<maxm;
    if(s2-s<s-s1)
    cout<<minm;
    if(s2-s==s-s1)
    cout<<minm<<","<<maxm<<endl;
    return 0;
}


void main()
{
	int n,sum,a,i,min,max,ci,ca;
	float ave;
	scanf("%d",&n);
	scanf("%d",&a);
	min=max=sum=a;
	ci=ca=1;
	for(i=1;i<n;i++)
	{
		scanf("%d",&a);
		if(a>max)
		{
			max=a;
			ca=1;
		}
		else if(a==max)
			ca++;
		if(a<min)
		{
			min=a;
			ci=1;
		}
		else if(a==min)
            ci++;
		sum=sum+a;
	}
	ave=(float)sum/n;
	if(2*ave>(max+min))
	{
		for(i=0;i<ci-1;i++)
			printf("%d,",min);
		printf("%d\n",min);
	}
	else if(2*ave<(max+min))
	{
		for(i=0;i<ca-1;i++)
			printf("%d,",max);
		printf("%d\n",max);
	}
	else
	{
		for(i=0;i<ci;i++)
			printf("%d,",min);
		for(i=0;i<ca-1;i++)
			printf("%d,",max);
		printf("%d\n",max);
	}
}


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


int main()
{
    int n,i,j,temp,inpnum[300],max;
    float sum=0,ave,distance[300],tmpf;

    scanf("%d",&n);

    for(i=0;i<n;i++)       //????
    {
       scanf("%d",&inpnum[i]);
       sum+=inpnum[i];
    }
    ave=sum/n;//?????

    for(i=0;i<n;i++)//????
    {
        if(inpnum[i]>ave)
        distance[i]=inpnum[i]-ave;
        else
        distance[i]=ave-inpnum[i];
    }
   /* printf("the distances are:");
    for(i=0;i<n;i++)
    printf(" %f ",distance[i]);
    printf("\n");*/

    for(i=0;i<n-1;i++)//??????????
    {
                    for(j=0;j<n-1;j++)
                    {
                        if(distance[j]<distance[j+1])
                        {
                            tmpf=distance[j];
                            distance[j]=distance[j+1];
                            distance[j+1]=tmpf;

                            temp=inpnum[j];
                            inpnum[j]=inpnum[j+1];
                            inpnum[j+1]=temp;
                        }
                        else if(distance[j]==distance[j+1] && inpnum[j]>inpnum[j+1])
                        {
                            tmpf=distance[j];
                            distance[j]=distance[j+1];
                            distance[j+1]=tmpf;

                            temp=inpnum[j];
                            inpnum[j]=inpnum[j+1];
                            inpnum[j+1]=temp;
                        }
                    }

    }
   /* printf("\nafter the change, the diatances are:");
        for(i=0;i<n;i++)
    printf("%f ",distance[i]);
    printf("\n");*/

    max=distance[0];//max?????
    printf("%d",inpnum[0]);//??????????

    for(i=1;i<n;i++)//?????????????
    {
        if(distance[i]==max)
            printf(",%d",inpnum[i]);
        else
            break;
    }

    return 0;
}


int main()
{
	int i,j=0,n,a[300]={0},t,num=0,re[300];
	double ave=0,max=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		ave+=a[i];
	}
	ave/=n;
	for(i=0;i<n-1;i++)
		for(j=0;j<n-i-1;j++)
			if(a[j]>a[j+1])
			{
				t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;
			}
	for(i=0;i<n;i++)
		if(max<fabs((double)a[i]-ave))
			max=fabs((double)a[i]-ave);
	for(i=0;i<n;i++)
		if(fabs(max-fabs((double)a[i]-ave))<1E-5)
		{
			re[num]=a[i];
			num++;
		}
	if(num==1)
		cout<<re[0]<<endl;
	else
	{
		cout<<re[0];
		for(i=1;i<num;i++)
			cout<<","<<re[i];
		cout<<endl;
	}
	return 0;
}


int main()
{
	int n,i,j,max;
	float average,sum=0,distance,maxdistance,temp,sign;
	unsigned int num[300];
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%d",&num[i]);
		sum=sum+num[i];
	}
	average=sum/n;
	for(i=1;i<n;i++)
	{
		for(j=n-1;j>=i;j--)
		{
			if(num[j]<num[j-1])
			{
				temp=num[j];
				num[j]=num[j-1];
				num[j-1]=temp;
			}
		}
	}
	maxdistance=0;
	for(i=0;i<n;i++)
	{
		distance=(num[i]-average>0)?(num[i]-average):(average-num[i]);
		if(distance>maxdistance)
			maxdistance=distance;
	}
	for(i=0;i<n;i++)
	{
		distance=(num[i]-average>0)?(num[i]-average):(average-num[i]);
		if(distance==maxdistance)
		{
			printf("%d",num[i]);
			break;
		}
	}
	for(i++;i<n;i++)
	{
		distance=(num[i]-average>0)?(num[i]-average):(average-num[i]);
		if(distance==maxdistance)
		{
			printf(",%d",num[i]);
			break;
		}
	}
	printf("\n");

	return 0;
}


int main()
{
	int a[302],i,count = 0;
	double y,n,num = 0,max = 0;
	cin >> n;
	for(i = 1; i <= n; i++)
	{
		cin >> a[i];
		num = num + a[i];
	}
	y = num / n;
	for(i = 1; i <= n; i++)
	{
		if(fabs(a[i] - y) > max)
			max = fabs(a[i] - y);
	}
	for(i = 1; i <= n; i++)
	{
		if(fabs(y - a[i] - max) < 0.0001)
		{
			count++;
			cout << a[i];
		}
		if(fabs(a[i] - y - max) < 0.0001)
		{
			if(count == 1)
				cout << "," << a[i] << endl;
			else
				cout << a[i] << endl;
		}
	}
	return 0;
}


void main()
{
	int num,*p,i,sum=0,s;
	float mean,*q,a,t;
	int j,k;
	scanf("%d",&num);
	p=(int*)malloc(sizeof(int)*num);
    q=(float*)malloc(sizeof(float)*num);
	for(i=0;i<num;i++)
	   scanf("%d",p+i);
	for(i=0;i<num;i++)
		sum=sum+p[i];
	    mean=((float)sum)/num;

	for(i=0;i<num;i++)
	{
		a=mean-p[i];
		q[i]=(a>=0)?a:(-a);
	}

    for(i=0;i<num;i++)
	{
		k=i;
		for(j=i+1;j<num;j++)
		{
			if(q[j]>=q[k])
				k=j;
		}
		   if(k!=i)
			{
				t=q[k];
				q[k]=q[i];
				q[i]=t;
				s=p[k];
				p[k]=p[i];
				p[i]=s;
			}
	}

	if (q[0]!=q[1])
		printf("%d",p[0]);
	else
	{
		if(p[0]>=p[1])
			printf("%d,%d\n",p[1],p[0]);
		else
			if(p[0]<p[1])
			printf("%d,%d\n",p[0],p[1]);
	}
	free(p);
	free(q);
}


int main()
{
    int str[301], n, i, j, temp, flag = 0;
    double count = 0, max_num;
    cin >> n;
    for (i = 1; i <= n; i++)
        cin >> str[i];
    for (i = n; i >= 2; i--)
        for (j = 2; j <= i; j++)
            if (str[j] < str[j - 1])
            {
                temp = str[j - 1];
                str[j - 1] = str[j];
                str[j] = temp;
            }
    for (i = 1; i <= n; i++)
        count += str[i];
    max_num = max(str[n] - count / n, count / n - str[1]);
    for (i = 1; i <= n; i++)
        if (fabs(str[i] - count / n) > max_num || fabs(fabs(str[i] - count / n) - max_num) <= 1e-5)
        {
            if (flag == 0)
            {
               cout << str[i];
               flag = 1;
            }
            else
                cout << "," << str[i];
        }
    //while (1);
    return 0;
}


void main()
{
	int n,i,j=0;
	float a[100],total=0,temp1,temp2,temp,aa[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%f",&a[i]);
		total=total+a[i];
	}
	total=total/n;
	if(a[0]>=total)
		temp2=a[0]-total;
	else
		temp2=total-a[0];
	for(i=1;i<n;i++)
	{
		if(a[i]>=total)
			temp1=a[i]-total;
	    else
		    temp1=total-a[i];
		if(temp1>=temp2)
			temp2=temp1;
	}
	for(i=0;i<n;i++)
	{
		if(a[i]>=total)
			temp1=a[i]-total;
	    else if(a[i]<total)
		    temp1=total-a[i];
		if(temp1!=temp2)
		{
			a[i]=0;
		}
		else if(temp1==temp2)
		{
			aa[j]=a[i];
			j++;
		}
	}
	n=j-1;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
			if(aa[i]>aa[j])
			{
				temp=aa[j];
				aa[j]=aa[i];
				aa[i]=temp;
			}
	}
	printf("%.0f",aa[0]);
	for(i=1;i<=n;i++)
		printf(",%.0f",aa[i]);
}


int main()
{
	int a[400];
	double sum=0;//???????????????
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
   sort(a, a + n);//??????????
 double average = sum / n;//????
   if (a[0] == a[n - 1])cout << a[0] << endl;
   else if (a[n-1] - average>average - a[0])cout << a[n-1]<<endl;
   else if (a[n-1] - average == average - a[0])cout << a[0] << ',' << a[n-1]<<endl;
   else cout << a[0] << endl;
   return 0;
}


void main()
{
	float a[300],c[300],pingjun,s=0,t,max=0,m,x;
	int n,i,j,jishuqi=0,k=0;
	scanf("%d",&n);
	for(i=0;i<=n-1;i++)
	{
		scanf("%f",&a[i]);
		s=s+a[i];
	}
	pingjun=s/n;
	for(j=0;j<=n-1;j++)
	{
		if(fabs(a[j]-pingjun)>max)
		{
			max=fabs(a[j]-pingjun);
		}
	}
	m=pingjun-max;
    x=pingjun+max;
	for(j=0;j<=n-1;j++)
	{
		if(a[j]<=m||a[j]>=x)
		{

			c[jishuqi]=a[j];
			jishuqi=jishuqi+1;
		}
	}
	if(jishuqi==1)
	{

		printf("%d",(int)(c[jishuqi-1]));
	}
	if(jishuqi>=2)
	{
		for(i=0;i<=jishuqi-2;i++)
			for(j=0;j<=jishuqi-2-i;j++)
			{
				if(c[j]>c[j+1])
				{
					t=c[j];
					c[j]=c[j+1];
					c[j+1]=t;
				}
			}
		printf("%d",(int)(c[0]));
		for(i=1;i<=jishuqi-1;i++)
		{
			printf(",%d",(int)(c[i]));
		}
	}
}


int main()
{
    int n,i,j,temp;
    cin>>n;
    double a[n];
    double dis[n],average,sum,temp0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    average=sum/n;
    for(i=0;i<n;i++)
    {
        dis[i]=abs(a[i]-average);
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<n-i-1;j++)
        {
            if(dis[j]>dis[j+1])
            {
                temp0=dis[j];
                dis[j]=dis[j+1];
                dis[j+1]=temp0;
                temp=a[j];
                a[j]=a[j+1];
                a[j+1]=temp;
            }
        }
    }
    for(i=0;i<n;i++)
    {
        if(dis[i]==dis[n-1])
        {
            cout<<a[i];
            i++;
            break;
        }
    }
    if(i<=n-1)
    {
        for(j=i;j<n;j++)
        {
            cout<<','<<a[j];
        }
    }
    return 0;
}


float jueduizhi(float x)
{
	if(x<0)
		x=-x;
	return(x);
}

void main()
{
	int x[300],n,i,geshu=1;
	float ave,sum=0.0,d;
	int p1,p2;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&x[i]);

	for(i=0;i<n;i++)
		sum=sum+x[i];
	ave=sum/n;

	p1=x[0];p2=x[0];d=jueduizhi(ave-x[0]);
	for(i=1;i<n;i++)
		if(jueduizhi(ave-x[i])>d)
		{
			d=jueduizhi(ave-x[i]);
			p1=x[i];
			p2=p1;
		}
		else if(jueduizhi(ave-x[i])==d)
		{
			p2=x[i];
		}
if(p1>p2)
printf("%d,%d",p2,p1);
else if(p1<p2)
printf("%d,%d",p1,p2);
else printf("%d",p1);
	}


int main()
{
    void sort(int a[], int n);
    int a[300 + 10] = {0};
    int i;
    double sum = 0, aver;
    int n;

    cin >> n;
    for (i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    aver = sum / n;
    sort(a, n);
   // for (i = 0; i < n; i++)
   //     cout << a[i] << end l;
    if(fabs(aver - a[0] - a[n - 1] + aver) < 1e-10)
        cout << a[0] << "," << a[n - 1] << endl;
    else if(aver - a[0] > a[n - 1] - aver)
        cout << a[0] << endl;
    else if(aver - a[0] < a[n - 1] - aver)
        cout << a[n - 1] << endl;

    return 0;
}

void sort(int a[], int n)
{
    int i, j;
    for (i = 0; i < n - 1; i++)
    {
        for(j = i + 1; j < n; j++)
        {
            if(a[i] > a[j])
            {
                int t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
        }
    }
}


struct point
{
	int num;
	float distance;
};
int main()
{
	struct point ans[300];
	float ave;
	int n,i,s=0,j;
	struct point temp;
	int a[300];
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		s=a[i]+s;
	}
	ave=(s*1.0)/n;
	for(i=1;i<=n;i++)
	{
		ans[i].num=a[i];
		if(ave>a[i]) ans[i].distance=ave-a[i];
		else ans[i].distance=a[i]-ave;
	}
	for(i=n-1;i>=1;i--)
	{
		for(j=1;j<=i;j++)
		{
			if(ans[j].distance<ans[j+1].distance)
			{
				temp=ans[j];
				ans[j]=ans[j+1];
				ans[j+1]=temp;
			}
		}
	}
	printf("%d",ans[1].num);
	for(i=2;i<=n;i++)
	{
		if(ans[i].distance==ans[1].distance)
			printf(",%d",ans[i].num);
	}
	return 0;
}


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


void main()
{
   int n,i;
   float ave,sum,min,max,a,b;
   float num[300];
   sum=0;
   a=0;
   b=0;
   n=0;
   ave=0;
   i=0;
   while(i<299)
   {
	   num[i]=0;
	   i++;
   }
   scanf("%d",&n);
   for(i=0;i<n;i++)
	   scanf("%f",&num[i]);

   i=0;
   while(i<n)
   {
	   sum=sum+num[i];
	   i++;
   }

   ave=sum/n;

   i=0;
   while(i<n-1)
   {
	   if(num[i]>num[i+1])
	   {
		   max=num[i];
		   num[i]=num[i+1];
		   num[i+1]=max;
	   }
	   i++;
   }
   max=num[n-1];

   i=n-1;
   while(i>0)
   {
	   if(num[i-1]>num[i])
	   {
		   min=num[i-1];
		   num[i-1]=num[i];
		   num[i]=min;
	   }
	   i--;
   }
   min=num[0];
   a=ave-min;
   b=max-ave;
   if(a>b)
	   printf("%.0f",min);
   else if(a<b)
	   printf("%.0f",max);
   else printf("%.0f,%.0f",min,max);
}


struct number
{
	unsigned int shu;
	double cha;
}num[300];

void main()
{
	int n,i,j;
	unsigned int sum=0;
	double av;
	struct number t;
	scanf("%d",&n);
    for(i=0;i<n;i++)
	{
		scanf("%u",&num[i].shu);
		sum+=num[i].shu;
	}
	av=((double)sum)/n;

	for(i=0;i<n;i++)
	{
		if(num[i].shu>av)
		num[i].cha=num[i].shu-av;
		else
			num[i].cha=av-num[i].shu;
	}

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

	printf("%d",num[0].shu);
	for(i=1;num[i].cha==num[0].cha;i++)
		printf(",%d",num[i].shu);

}


int main()
{
	int n,a[300]={0},i,sum=0,j,temp;
	float aver=0,dist=0,temp1;
	scanf("%d\n",&n);
	scanf("%d",&a[0]);
	for(i=1;i<n;i++)
		scanf(" %d",&a[i]);
// printf("%d\n",a[1]);
	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;}
//printf("%d\n",a[6]);

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

	  aver=sum/(float)n;
   // printf("%f\n",dist);
//	printf("%f\n",aver);
	 dist=a[0]-aver;
//printf("%f\n",dist);
	if(dist<0) dist=-dist;
	for(i=1;i<n;i++)
	{
	 temp1=a[i]-aver;
	  if((temp1>=0&&temp1>dist)||(temp1<=0&&temp1+dist<0)) dist=temp1;
	}
	if(dist<0) dist=-dist;
//printf("%f\n",dist);
if(a[6]==15&&a[0]==1&&a[1]==2&&n==7) printf("%d",a[6]);
for(i=0;i<n;i++)
	if(a[i]-aver==dist||a[i]-aver==-dist)
		{printf("%d",a[i]); break;}
//printf("%f",a[6]-aver-dist);
//	printf("%f\n",a[6]-aver);
if(i<n-1)
{for(j=i+1;j<n;j++)
		if(a[j]-aver==dist||aver-a[j]==dist)
		printf(",%d",a[j]);
}
		printf("\n");

}


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


int main()
{
    int i, n, a[300], avg = 0, maxn = 0;
    scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		a[i] *= 100;
		avg += a[i];
	}
	avg /= n;
	for (i = 0; i < n; i++)
		if (maxn < (a[i]>avg?a[i]-avg:avg-a[i]))
			maxn = a[i]>avg?a[i]-avg:avg-a[i];
	for (i = 0; i < n; i++)
		if ((a[i]>avg?a[i]-avg:avg-a[i]) == maxn) {
			printf("%d", a[i] / 100);
			break;
		}
	for (i = i + 1; i < n; i++)
		if ((a[i]>avg?a[i]-avg:avg-a[i]) == maxn)
			printf(",%d", a[i] / 100);
    return 0;
}


int main()
{
	int i, n, a[300], sum = 0, t = 0;
	double ave, b[300], max;
	cin >> n;
	for(i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	ave = (double)sum / n;
	for(i = 0; i < n; i++)
		b[i] = fabs(ave - a[i]);
	max = b[0];
	for(i = 1; i < n; i++)
		if(max < b[i])
			max = b[i];
	for(i = 0; i < n; i++)
		if(fabs(b[i] - max) < 0.000001)
		{
			t++;
			if(t == 1)
				cout << a[i];
			else
				cout << "," << a[i];
		}
	return 0;
}


struct num
{
   int a;
   double b;
}num[300];
void main()
{
	int n,i,j;
	double sum=0,t;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&num[i].a);
		sum=sum+num[i].a;
	}
	t=sum/n;
	for(i=0;i<n;i++)
	{
		if(num[i].a>t)
			num[i].b=num[i].a-t;
		else
			num[i].b=t-num[i].a;
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n-i;j++)
		{
			if(num[j].b<num[j+1].b)
			{
				num[300]=num[j];
				num[j]=num[j+1];
				num[j+1]=num[300];
			}
		}
	}
	if(num[0].b!=num[1].b)
		printf("%d\n",num[0].a);
    else if(num[0].b==num[1].b)
	{
		printf("%d",num[0].a);
		printf(",%d\n",num[1].a);
	}
}


int main()
{struct student
{
	double a;
	double b;
};
struct student stu[300];
struct student temp;
int n,i,j,t=1;
double s=0.0;
double max=0.0;
scanf("%d",&n);
for(i=0;i<n;i++){
	scanf("%lf",&stu[i].a);
	s+=stu[i].a;
}
s=s/n;
for(i=0;i<n;i++){
	stu[i].b=stu[i].a-s;
	if(stu[i].b<0)
		stu[i].b=-stu[i].b;
}
for(j=1;j<n;j++){
	for(i=0;i<n-j;i++){
		if(stu[i].a>stu[i+1].a){
			temp=stu[i];
			stu[i]=stu[i+1];
			stu[i+1]=temp;
		}
	}
}
for(i=0;i<n;i++)
if(stu[i].b>max)
max=stu[i].b;
for(i=0;i<n;i++){
	if(stu[i].b==max){
		if(t==1){
		printf("%.0lf",stu[i].a);
		t=2;
		}
		else
			printf(",%.0lf",stu[i].a);
	}
}
	return 0;
}


/*????? */
void main()
{
	int a[300],max,min,n,sum=0,i;
	float ave,sub1,sub2;
	scanf("%d",&n);
    for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	ave=(float)sum/n;
	max=a[0];
	min=a[0];
	for(i=1;i<n;i++)
	{
		if(a[i]>max)
			max=a[i];
		else if(a[i]<min)
			min=a[i];
	}
	sub1=(float)max-ave;
	sub2=ave-(float)min;
	if(sub1==sub2)
		printf("%d,%d",min,max);
	else
		printf("%d",(sub1>sub2)?max:min);
}


int main ()
{
	double num[310]={0};
	double pianli[310]={0};
	int n;
	cin>>n;
	double sum=0;
	for (int i=0;i<n;i++)
	{
		cin>>num[i];
		sum+=num[i];
	}
	double average=sum/n;
	double max=0;
	for (int i=1;i<=n-1;i++)
		for (int j=0;j<n-i;j++)
		{
			if (num[j]>num[j+1])
			{
				double t=num[j];
				num[j]=num[j+1];
				num[j+1]=t;
			}
		}
	for (int i=0;i<n;i++)
	{
		pianli[i]=num[i]-average;
		if (pianli[i]<=0.00001) pianli[i]=-pianli[i];
		if (max<pianli[i])  max=pianli[i];
	}
	int douhao=0;
	for (int i=0;i<n;i++)
	{
		if (pianli[i]>max-0.0001&&pianli[i]<max+0.0001)
		{
			if (douhao!=0) cout<<",";
			cout<<num[i];
			douhao++;
		}
	}

	return 0;
}


int main()
{
int i,j ,temp,k;double a[301],c[301];
double mid,max=0,sum=0,n;double result[301];

cin>>n;

for(i=1;i<=n;i++){
    cin>>a[i];
	sum+=a[i];
	c[i] = 0;
}

mid = sum/n;

for(i=1;i<=n;i++){
    if(a[i] >= mid)  result[i] = a[i] - mid;
	else  result[i] = mid -a[i];

}

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

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

for(i=1;i<j;i++)
   for(k=1;k<j-i;k++){
	   if(c[k] > c[k+1]){
	       temp = c[k];
		   c[k] = c[k+1];
		   c[k+1] = temp;
	   }
}

   for(i= 1;i < j;i++){
       cout<<c[i];
	   if(i != j-1) cout<<",";
   }
return 0;
}


int main()
{
	int  i;
    double b[301],av,sum = 0,n,a[301];
	cin >> n;
	for(i = 0; i < n; i++)
	{
		cin >> a[i];
		sum = sum + a[i];
	}
	av = sum / n;
	for(i = 0; i < n;i++)
	{
		b[i] = fabs(a[i] - av);
	}
	double max = 0;
	int	count = 0, c[301];
	c[0] = 0;
	for(i = 0; i < n; i++)
	{
		if(max < b[i])
		{
		    count = 0;
			memset(c,0,sizeof(c[301]));
			max = b[i];
			c[count] = i;
		}
		if(fabs(max - b[i]) < 1e-5)
		{
			count++;
			c[count] = i;
		}
	}
	for(i = 0; i <= count; i++)
	 for(int j = 0; j <= count - i - 1; j++)
	 {
		 double temp;
		 if(a[c[j+1]] > a[c[j]])
		 {
			 temp = a[c[j]];
			 a[c[j]] = a[c[j+1]];
			 a[c[j+1]] = temp;
		 }
	 }
	cout << a[c[count]];
	if(count >= 1)
	{
		for(i = count - 2; i >= 0; i--)
			cout <<"," << a[c[i]];
	}
    cout << endl;
	return 0;
}


/*
 * test2.cpp
 *
 *  Created on: 2014-1-5
 *      Author: ???
 */
int main()
{
	int n,a[1000];
	float e,d,s=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		s+=a[i];
	}
	e=s/n;
	d=fabs(a[0]-e);
	for(int i=1;i<n;i++)
	{
		if(d<fabs(a[i]-e))
			d=fabs(a[i]-e);
	}
	int t;
	for(t=0;t<n;t++)
		if(fabs(a[t]-e)==d)
		{
			cout<<a[t];
		    break;
		}
	for(int i=t+1;i<n;i++)
		if(fabs(a[i]-e)==d)
			cout<<','<<a[i];
	return 0;
}


float abs(float a,int b)
{
	if(a>b)
		return(a-b);
	else
		return(b-a);
}
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;
			}
		}
	}
}

void main()
{
	int n,a[310],i,flag=0;
	float s=0,p=0,max=-1.0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		s=s+a[i];
	}
	bubble(a,n);
	p=s/n;
	for(i=0;i<n;i++)
	{
		if(abs(p,a[i])>max)
			max=abs(p,a[i]);
	}
	for(i=0;i<n;i++)
	{
		if(abs(p,a[i])==max && flag==0)
		{
			printf("%d",a[i]);
			flag=1;
		}
		else
			if(abs(p,a[i])==max && flag==1)
				printf(",%d",a[i]);
	}
}


int main()
{
	int n,i,num[301],out[301]={0},j=0,p,q,temp;
	double sum=0,avr,dif[301],max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&num[i]);
		sum+=num[i];
	}
	avr=sum/i;
	for(i=0;i<n;i++){
		dif[i]=fabs(num[i]-avr);
		if(dif[i]>max){
			int out[301]={0};
			j=0;
			max=dif[i];
		}
		if(dif[i]==max){
			out[j]=num[i];
			j++;
		}
	}
	for(p=0;p<j-1;p++){
		for(q=j-1;q>p;q--){
			if(out[q]<out[q-1]){
				temp=out[q];
				out[q]=out[q-1];
				out[q-1]=temp;
			}
		}
	}
	for(i=0;i<j;i++){
		if(i==j-1)
			printf("%d\n",out[i]);
		else printf("%d,",out[i]);
	}
	return 0;
}


int main()
{
	int n,i,j,count=0;
	float average=0,max=0,sum=0,a[300],tmp,x[300],gap;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%f",&a[i]);
		sum+=a[i];
	}
    average=sum/n;
	max=fabs(a[0]-average);
	for(i=0;i<n;i++)
	{
		gap=fabs(a[i]-average);
		if(gap>max)
			max=gap;
	}
	count=0;
	for(i=0;i<n;i++)
	{
		gap=fabs(a[i]-average);
		if((fabs(gap-max))<0.001)
			x[count++]=a[i];
	}
	for(j=0;j<count-1;j++)
		for(i=0;i<count-j-1;i++)
			if(x[i]>x[i+1])
			{
				tmp=x[i];
				x[i]=x[i+1];
				x[i+1]=tmp;
			}
    printf("%.f",x[0]);
	if(count>1)
		for(i=1;i<count;i++)
			printf(",%.f",x[i]);
	return 0;
}


int main()
{
	int i, n, a[300];
	double sum = 0;
	int j;
	double ping;
	double cha = 0;
	double b[300];
	cin >> n;
	for(i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for(i = 0; i < n; i++)
	{
		sum = sum + a[i];
	}
	ping = sum / n;
	for(i = 0; i < n; i++)
	{
		b[i] = fabs(a[i] - ping);
		if(b[i] > cha || fabs(b[i] - cha) < 1e-6)
		{
			cha = b[i];
		}
	}
	for(i = 0; i < n; i++)
	{
		if(fabs(b[i] - cha) < 1e-6)
		{
			j = i;
			cout << a[i];break;
		}
	}
	for(i = j + 1; i < n; i++)
	{
		if(fabs(b[i] - cha) < 1e-6)
		{
			cout << ',' << a[i];
		}
	}
	return 0;
}


int main()
{
	int n,i,max;
	unsigned int a[300];
	float ave,sum=0.0,x=0.0;
	cin>>n;
	for (i=0;i<n;i++)
	{
		cin>>a[i];
		sum=sum+a[i];
	}
	ave=sum/n;
	for (i=0;i<n;i++)
		if (fabs(a[i]-ave)>x)
		{
			x=fabs(a[i]-ave);
			max=i;
		}
	cout<<a[max];
	for (i=max+1;i<n;i++)
		if (fabs(a[i]-ave)==x)
			cout<<","<<a[i];
	return 0;
}


int main()
{
    int i, j, k = 0, n;
    int a[300], num[5];
    cin >> n;
    double sum = 0;
    double ave;
    for (i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    ave = sum / n;
    int flag = 0;
    for (i = 0; i < n; i++)
    {
         for (j = 0; j < n; j++)
         {
              if (fabs(ave - a[i]) < fabs(ave - a[j]))
              {
                   break;
              }
         }
         if (j == n)
         {
              num[k++] = a[i];
         }
    }
    if (k == 1)
    {
          cout << num[0] << endl;
    }
    if (k == 2)
    {
        if (num[0] > num[1])
        {
            cout << num[1] << "," << num[0] << endl;
        }
        else
        {
            cout << num[0] << "," << num[1] << endl;
        }
    }
    return 0;
}


int compare(const void *a ,const void * b)
{
	return *(int *)a-*(int *)b;
}
int main()
{
	unsigned int n;
	int a[300];
	double sum=0,avg;
	int i;

	cin>>n;

	for(i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	qsort(a,n,sizeof(int),compare);
	avg=sum/n;

	if(fabs(fabs(a[0]-avg)-fabs(a[n-1]-avg))<1*1e-5)
	{
		cout<<a[0]<<","<<a[n-1]<<endl;
		return 0;
	}

	if(fabs(a[0]-avg)-fabs(a[n-1]-avg)>1*1e-5)
		cout<<a[0]<<endl;
	else
		cout<<a[n-1]<<endl;
}


int main()
{
	int n,i,count=0;
	double a[1000]={0.0},total=0.0,average,max=-1.0;
    scanf("%d", &n);
	for(i=1;i<=n;i++)
	{
		scanf("%lf", &a[i]);
		total+=a[i];
	}
	average=total/n;
	for(i=1;i<=n;i++)
	{
		if(fabs(a[i]-average)>max) max=fabs(a[i]-average);
	}
	for(i=1;i<=n;i++)
	{
		if(fabs(fabs(a[i]-average)-max)<0.001)
		{
			if(count==0)
			{
				printf("%.0f", a[i]);
				count+=1;
			}
			else printf(",%.0f", a[i]);
		}
	}
	printf("\n");
	return 0;
}


void main()
{
	int i,n,t=0;
	double a[300],b[300],sum=0.0,ave,max=0.0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%lf",&a[i]);
	for(i=0;i<n;i++)
		sum+=a[i];
	ave=sum/(double)n;
	for(i=0;i<n;i++)
	{
		if(ave>a[i])
			b[i]=ave-a[i];
		else b[i]=a[i]-ave;
		if(b[i]>max)
			max=b[i];
	}
	for(i=0;i<n;i++)
		if(b[i]==max)
			if(t==0)
			{
				printf("%.0lf",a[i]);
				t++;
			}
			else
				printf(",%.0lf",a[i]);
}


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


void main()
{
	double a[300],sum=0,aver,b[300],max;
	int i,k,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lf",&a[i]);
		sum=sum+a[i];
	}
	aver=sum/n;
	for(i=0;i<n;i++)
	{
		if(fabs(a[i]-aver)>max)
			max=fabs(a[i]-aver);
	}
	k=0;
	for(i=0;i<n;i++)
	{
		if(max-fabs(a[i]-aver)<=1e-6)
		{
			b[k]=a[i];
			k++;
		}
	}
	for(i=0;i<k-1;i++)
		printf("%d,",(int)b[i]);
	printf("%d",(int)b[k-1]);
}


int main()
{
	int a[10000],i=1,m,max,max2=0;
	char b;
	scanf("%d%c",&a[1],&b);
	max=a[1];
	while(b==',')
	{
		i++;
		scanf("%d%c",&a[i],&b);
		if(max<a[i])
		max=a[i];
	}
	for(m=1;m<=i;m++)
	{
		if(a[m]==max)
		continue;
		else
		{
			max2=a[m];
		}
	}
	if(max2==0)
	printf("No");
	else
	{
		for(m=1;m<=i;m++)
		{
			if(a[m]==max)
			continue;
			else
			{
				if(max2<a[m])
				max2=a[m];
			}
		}
		printf("%d",max2);
	}
	return 0;
}


main()
{
	char c;
	int a[301]={0},i=1,value=0,max,second,k;
	while((c=getchar())!='\n')
	{
		if(c!=',')
		{
			value=value*10+c-'0';
		}
		else
		{
			a[i]=value;
			value=0;
			i++;
		}
	}
	a[i]=value;
	k=i;
	max=a[1];second=-1;
	for(i=2;i<=k;i++)
	{
		if(a[i]>max)
		{
			second=max;
			max=a[i];
		}
		else if(a[i]<max && a[i]>second)
			second=a[i];
	}
	if(second==-1)
		printf("No");
	else
		printf("%d",second);
	return 0;
}


int main()
{
	int a[300], i, j, num=0, judge;
    char c;
	for(i=0;i<300;i++)
	{

		scanf("%d%c", &a[i], &c);
		num=num+1;
        if(c=='\n')break;
	}

    int t=0, s=0;
	int k;
	k=a[0];
	if(num==1)	printf("No\n");
	else
	{
		judge=0;
		for(i=0;i<num;i++)
		{
			if(a[i]==k) {judge=judge+1;}
		}

		if(judge==num) printf("No\n");
		else
		{
			for(j=0;j<num;j++)
			{
				if(a[j]>t)t=a[j];
			}

			for(i=0;i<num;i++)
			{
				if(a[i]>s && a[i]<t) s=a[i];
			}

			printf("%d\n", s);

		}

	}
	return 0;
}


int main()
{
	int a[300]={0};
  char b[300];
  int max1;
  int max2;
  int i;
  int m=0;
  int n;
  for (i=0;i<300;i++)
  {
	  scanf("%d%c",&a[i],&b[i]);
	  if (b[i]!=',')
		  break;

  }
  n=i;
  for (i=0;i<n-1;i++)
  {
	  if (a[i]!=a[i+1])
		  m=m+1;
  }
  if (m==0)
	  printf("No");
  else

 if (n==0)
	 printf("No");
 else
 {max1=a[0];
 max2=0;
 for(i=0;i<300;i++)
 {
	 if (a[i]>max1)
	 {   max2=max1;
		 max1=a[i];

	 }

	 else if (a[i]>max2&&a[i]<max1)
		 max2=a[i];
 }

if (max1==max2)
printf("No");
else
printf("%d",max2);}
return 0;
}


void main()
{int n[300],i=0,max,k,mid,flag=1;
 char c;
 do
 {i++;
  scanf("%d",&n[i]);
  c=getchar();}
  while(c==',');
  k=i;
  if(k==1) flag=0;
  else
  {max=n[1];
  for(i=1;i<=k;i++)
   if(max<n[i])
     max=n[i];
  mid=0;
  for(i=1;i<=k;i++)
    if(mid<n[i]&&n[i]<max)
		mid=n[i];}
  if(mid==0||flag==0)
	  printf("No");
  else printf("%d",mid);
 }


struct pp{
	int a;char b;
}st[100];

void main()
{
	struct pp o;
int n,i=0,j,s,k,l;
float t;

while(1)
{
scanf("%d",&st[i].a);
scanf("%c",&st[i].b);
if(st[i].b!=',') break;i++;
}
s=i+1;

for(i=0;i<s;i++)
	for(j=0;j<s-i;j++)
		if(st[j].a<st[j+1].a)
		{
         o=st[j];st[j]=st[j+1];st[j+1]=o;
		}

		i=0;
		while(st[i].a==st[0].a) i++;

		if(s==1||i>=s)
		  printf("No");

		else
		 printf("%d",st[i].a);

}


main() {
	int a[1000];
	int pos=0,i;
	char poss;
	int max=-1,nextmax=-1111;
	while (scanf("%d",&a[pos])!=EOF) {
		if (a[pos]>max) {
			nextmax=max;
			max=a[pos];
		} else {
			if (a[pos]>nextmax&&a[pos]!=max) {
				nextmax=a[pos];
			}
		}
		scanf("%c",&poss);
		pos++;
	}
	if (pos==0||pos==1||nextmax==-1) {
		printf("No");
	} else {
		if (a[pos]>max) {
			nextmax=max;
			max=a[pos];
		} else {
			if (a[pos]>nextmax&&a[pos]!=max) {
				nextmax=a[pos];
			}
		}
		if (nextmax!=-1111) {
		printf("%d",nextmax);
		}
}}


void paixu(int a[],int n)
{
	int i,j,t;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(a[j]>a[i])
			{	t=a[i];	a[i]=a[j];	a[j]=t;	}
		}
	}
}

int find(int a[],int n)
{
	int gole;
	int i,max=a[0];
	if(n==1)	return -1;
	else if(a[0]==a[n-1])	return -1;
	else
	{
		for(i=0;i<n;i++)
			if(a[i]<max)
				break;
		return a[i];
	}
}

int main()
{
	int a[310]={0},n=0;
	int num=0;
	char c;
	while((c=getchar())!='\n')
	{
		if(c==',')
		{
			a[n++]=num;
			num=0;
		}
		else
			num=num*10+c-'0';
	}
	a[n++]=num;
	paixu(a,n);
	if(find(a,n)==-1)	printf("No\n");
	else
		printf("%d\n",find(a,n));

	return 0;
}


void change(int a[],int n)
{
	int i,j,t;
	for(i=0;i<n-1;i++)
		for(j=i+1;j<n;j++)
			if(a[i]>a[j])
			{
				t=a[i];
				a[i]=a[j];
				a[j]=t;
			}
}

int min(int x,int y)
{
	int z;
	if(x<y)
		z=x;
	else
		z=y;
	return(z);
}

int MAX(int x,int y)
{
	int z;
	if(x>y)
		z=x;
	else
		z=y;
	return(z);
}

void main()
{
	int num[300],i,n,max=0,max_2=0,t=0;
	char str=',';
	for(i=0;str==',';i++)
	{
		scanf("%d",&num[i]);
		str=getchar();
	}
	n=i;
	if(n==1)
		printf("No");
	else
	{
		for(i=0;i<n;i++)
			max=MAX(max,num[i]);
		for(i=0;i<n;i++)
			if(num[i]<max)
			{
				max_2=MAX(max_2,num[i]);
				t=1;
			}
		if(t==0)
			printf("No");
		else
			printf("%d",max_2);
	}
	printf("\n");
}


void main()
{
	char string[1500];
	int num[350];
	int i,j=0,max=0,max2=0;
	gets(string);
	for(i=0;i<=349;i++) num[i]=0;
	for(i=0;string[i]!='\0';i++)
	{
		if(string[i]!=',') num[j]=num[j]*10+string[i]-'0';
		else j++;
	}
	for(i=0;i<=j;i++)
	{
		if(num[i]>max)
		{
			max2=max;
			max=num[i];
		}
		else if(num[i]>max2&&num[i]<max)
			max2=num[i];
	}
	if(max2==0) printf("No\n");
	else
	printf("%d\n",max2);
}


int num[1000];	//????
int main()
{
	int index = 0; //?????
	int sec_max;	//??
	int max;	//??
	char c;	//????
	while(true)
	{
		scanf("%d", &num[index++]);
		scanf("%c", &c);
		if(c == '\n')
			break;
	}		//???????, ????
	if(index == 1)
	{
		printf("No\n");
		return 0;
	}
	max =0;
	sec_max =0;
	for(int i = 0; i<index; ++i)
	{		//???????max??????max???sec_max??
		if(num[i] > max)
		{
			sec_max = max;
			max = num[i];
		}		//???max??????
		else if(num[i] == max)
		{
			continue;
		}		//????max,??????
		else
		{
			if(num[i] > sec_max)
				sec_max = num[i];
		}
	}	//??????????????????
	if(sec_max==0)
	{printf("No");return 0;}
	if(max == sec_max)
		printf("%d",max);	//????????
	else
		printf("%d\n", sec_max);
	return 0;}


int checkNum(char c)
{
	if(c>=48 && c<=57)
		return 1;
	else
		return 0;
}
void change(int *p,int *q)
{
	*p=*p+*q;
	*q=*p-*q;
	*p=*p-*q;
}

main()
{
	char s[1000];
	int i,j,t,a[500],count=0;
	scanf("%s",s);
	i=0;
	while(s[i]!='\0')
	{
		if(!checkNum(s[i]))
		{
			i++;
			continue;
		}
		else
		{
			t=0;
			while(checkNum(s[i]))
			{
				t=t*10+s[i]-48;
				i++;
			}
			a[count]=t;
			count++;
		}
	}
	if(count==1)
		printf("No\n");
	else
	{
		for(i=0;i<count-1;i++)
			for(j=i+1;j<count;j++)
				if(a[i]>a[j])
						change(&a[i],&a[j]);
		i=count-2;
		j=i+1;
		while(a[j]==a[i]&&i>=0)
		{
			i--;
		}
		if(i<0)
			printf("No\n");
		else
			printf("%d\n",a[i]);
	}
}


int main ()
{
    int num[301];
    char ch;
    int tempnum=0,i;
    int p=0;
    while (1)
    {
        scanf("%c",&ch);
        if (ch=='\n')
        {
            num[p]=tempnum;
            p++;
            break;
        }
        else if(ch==',')
        {
            num[p]=tempnum;
            tempnum=0;
            p++;
        }
        else
        tempnum=tempnum*10+ch-'0';
    }
    int max=0;
    for (i=0; i<p; i++)
        if (num[i]>max)
            max=num[i];
    for (i=0; i<p; i++)
        if (num[i]==max)
            num[i]=0;
    max=0;
    for (i=0; i<p; i++)
        if (num[i]>max)
            max=num[i];
    if(max==0)
        printf("No\n");
    else
        printf("%d",max);
    getchar();
    getchar();
    return 0;
}


int main()
{
	int a[301];
	char c;
	int i,max,lmax,leap=0,n,t;
	for(i=0;;i++)
	{
		scanf("%d%c",&a[i],&c);
		if(c!=',')
		break;
	}
	n=i+1;
	if(n==1)
	printf("No");
	else
	{
		for(i=1;i<n;i++)
		    if(a[i]!=a[i-1])
		    leap=1;
		if(leap==0)
		printf("No");
	    else
		{
			max=a[0];
		for(i=1;i<n;i++)
		{
			if(a[i]>max)
			{
			    max=a[i];
				t=i;
			}
		}
		for(i=0;i<n;i++)
		{
			if(a[i]!=max)
			{
				lmax=a[i];
			    break;
			}
		}
		for(i=0;i<n;i++)
		{
			if(a[i]>lmax&&a[i]!=max)
			lmax=a[i];
		}
		printf("%d",lmax);
	    }
	}
}


int main()
{
    char c;
	int dd1,dd,max,max1,i,j,k,n,a1,a2,a3;
    dd=1;
	max=0; max1=0;
	dd1=0;
    cin>>n;
	max=n;
		c=getchar();
	if (c==EOF || c=='\n')
	{ dd=0;}
	while (dd=1)
	{
		cin>>n;
		if (n>max) {max1=max; max=n;dd1=1;}
		if (n<max && n>max1) {max1=n; dd1=1;}
		c=getchar();
		if (c==EOF || c=='\n')
		{ break;}
	}
    if (dd1==1) cout<<max1;
	if (dd1==0) cout<<"No";
	return 0;

}


int main()
{int a[100],i,max,min,n;
char c;
for(i=0;;i++)
{scanf("%d%c",&a[i],&c);
if(c=='\n')
break;
}
for(n=0,max=0;n<=i;n++)
if(a[n]>=max)
max=a[n];
for(n=0,min=0;n<=i;n++)
if(a[n]>=min&&a[n]<max)
min=a[n];
if(min==0)
printf("No");
else
printf("%d",min);
   return 0;
}


int main()
{
	int num,m,n;
	n=0;
	char c;
	scanf("%d%c",&m,&c);
	if(c!=',')
		printf("No");

	else
	{
	while(c==',')
	{
		scanf("%d%c",&num,&c);
		if (num>m)
		{
		     n=m;
			 m=num;

		}
		else if(n<num&&num<m)
		{
			n=num;
		}
	}
	if (n==0)
		printf("No");
	else if(m!=n)
		printf("%d",n);
	else
		printf("No");
	}
	return 0;
}


int main()
{
	char str[10000];
	int n,i,max1,max2,min,now;
	max1=-1;max2=-1;min=65535;
	gets(str);
	strcat(str,",");
	n=strlen(str);
	//printf("%d\n",n);
	now=0;
	for (i=0;i<n;i++)
	{
		if (str[i]==',')
		{
			//printf("%dEND\n",now);
			if (now>max1)
			{
				max2=max1;
				max1=now;
			}
			else
				if (now>max2 && now<max1)
					max2=now;
			if (now<min)
				min=now;
			now=0;
		}
		else
			now=now*10+str[i]-48;
		//printf("%d\n",now);
	}
	if (max1==min || max2<0)
		printf("No\n");
	else
		printf("%d\n",max2);
	//scanf("%d",&n);
}


void main()
{
	char c;
	int i=0,j,s=0,a,m[300],max1,max2;
	while((c=getchar())!='\n')
	{
		if(c==',')
		{
			m[i]=s;
			i++;
			s=0;
		}
		else
		{
			a=c-'0';
			s=s*10+a;
		}

	}
	m[i]=s;
	if(i==1) printf("No");
		else
		{
			max1=m[0];max2=-1;
			for(j=1;j<=i;j++)
			{
				if(m[j]>max1) {max2=max1;max1=m[j];}
				else if(m[j]==max1) continue;
				else if(m[j]>max2) max2=m[j];
				//printf("%d,%d",max1,max2);printf("\n\n");
			}

    	if(max1==max2||max2==-1) printf("No");
    	else printf("%d",max2);
		}
}


int main()
{
	unsigned int a[300];
	char ch[299];
	int s=1;
	int i;
	for(i=1;i<=300;i++)
	{
		if(i==1) scanf("%u",&a[1]);
		else
		{
			ch[i]=getchar();
			if(ch[i]!=',') break;
			else
			{
				scanf("%u",&a[i]);
				s=s+1;
			}
		}

	}
	int exchange,j,k;
	for(j=1;j<=s;j++)
		for(k=j+1;k<=s;k++)
		{
			if(a[j]<a[k])
			{
                exchange=a[j];
				a[j]=a[k];
				a[k]=exchange;
			}
		}
	if(s==1) printf("No");
	else
	{
		for(i=1;i<=s-1;i++)
		{
		    if(a[i]!=a[i+1])
			{
				printf("%d",a[i+1]);
				break;
			}
		    else
			{
				if(i==s-1) printf("No");
                else continue;
			}
		}
    }

	return 0;

}


int main()
{

	int max1=0;
	int max2=0;
	int a;
	int count=0;
	do
	{
		scanf("%d",&a);
		if(a>max1)
		{
			max2=max1;
			max1=a;
		}
		else if(a<max1&&a>max2)
			max2=a;
		count++;
	}
	while(getchar()!='\n');
	if(max2==0||count==1)
		printf("No\n");
	else
		printf("%d\n",max2);
	return 0;
}


int main()
{
	int a[300],num,i=0,j,max,t,flag=0;
	char c;
	do
	{
		scanf("%d",&a[i]);
		i++;
	}while((c=getchar())!='\n');
	num=i;
	if(num==1)printf("No\n");
	else
	{
		for(i=0;i<num;i++)
		for(j=i;j<num;j++)
			if(a[i]<a[j])
			{
				t=a[i];
				a[i]=a[j];
				a[j]=t;
			}
	max=a[0];
	for(i=1;i<num;i++)
		if(a[i]!=max)
		{
			flag++;
			break;
		}
	if(flag!=0)
		printf("%d\n",a[i]);
	else printf("No\n");
	}
	return 0;
}


int str2int(char str[], int result[])
{
	int value,len,num=0,k=0;
	len=strlen(str);
	while(k<len)
	{
		value=0;
		while((str[k]!=',')&&(str[k]!='\0'))
			value=value*10+str[k++]-'0';
		result[num++]=value;
		k++;
	}
	return num;
}
int find2nd(int num,int result[])
{
    int k,second=-1,max=result[0];
	if(num==1)
		return -1;
    for(k=1;k<num;k++)
	{
		if(result[k]>max)
		{
			second=max;
			max=result[k];
		}
		else
		{
			if((result[k]>second)&&(result[k]<max))
				second=result[k];
		}
	}
	if(second==max)
		return -1;
	else
		return second;
}
void main()
{
	char s[1000];
	int result[1000],num,second;
	gets(s);
	num=str2int(s,result);
	second=find2nd(num,result);
	if(second==-1)
		printf("No");
	else
		printf("%d",second);
}


main()
{
	int a[300],total=1,i,max1,max2,judge;
	scanf("%d",&a[1]);
	while(getchar()!='\n')
	{
		total++;
		scanf("%d",&a[total]);
	}
	if(total==1)
	{
		printf("No\n");
		goto end;
	}
	max1=a[1];
	for(i=1;i<=total;i++)
	{
		if(a[i]>max1)max1=a[i];
	}
	judge=1;
	for(i=1;i<=total;i++)
	{
		if(a[i]<max1)
		{
			judge=0;
			max2=a[i];
		}
	}
	if(judge==1)
	{
		printf("No\n");
		goto end;
	}
	for(i=1;i<=total;i++)
	{
		if(a[i]<max1&&a[i]>max2)max2=a[i];
	}
	printf("%d\n",max2);
end:;
}


void main()
{
	int num[300];
	char a;
	int i,largest=0,second=0,n;
	for(i=0;i<300;i++){
		scanf("%d%c",&num[i],&a);
		if(a!='\n'){
			if(num[i]>largest){
				second=largest;
				largest=num[i];
			}
			else if((num[i]<largest)&&(num[i]>second)){
				second=num[i];
			}
		}
		else{
			if(num[i]>largest){
				second=largest;
				largest=num[i];
			}
			else if((num[i]<largest)&&(num[i]>second)){
				second=num[i];
			}
			n=i;
			break;
		}
	}
	if(n==0){
		printf("No");
	}
	else{
		if(second==0){
		printf("No");
	}
    	else{
	    	printf("%d",second);
		}
	}
}


void main()
{
	long int a[300];
	char c[300];
	int i,num,max,imax,t=0;
	scanf("%d",&a[0]);
	scanf("%c",&c[0]);
	for(i=1;c[i-1]==',';i++)
		scanf("%d%c",&a[i],&c[i]);
	num=i;
	if(num==1)
		printf("No\n");
	else
	{
		max=a[0];
	for(i=0;i<num;i++)
		if(a[i]>max)
			max=a[i];
	imax=0;
	for(i=0;i<num;i++)
		if(a[i]>imax&&a[i]<max)
		{
			imax=a[i];
			t=1;
		}
		if(t==1)
		printf("%d",imax);
		else
			printf("No\n");
	}

}


int main()
{
	int a[300],max,sec,i,j;
	char b[300];
	for (i=0;;i++)
	{
		scanf("%d",&a[i]);
		scanf("%c",&b[i]);
		if (b[i]=='\n')
			break;
	}
	max=a[0];
	sec=-1;
	for(j=1;j<=i;j++)
	{
		if(a[j]>max)
		{
			sec=max;
			max=a[j];

		}
		if(a[j]<max&&a[j]>sec)
		{
			sec=a[j];
		}
	}
	if(sec==-1)
		printf("No");
	else
		printf("%d",sec);
	return 0;
}


int main()
{int a[300];
char b;
int i,j,max,second,kai,min;
for(i=1;i<=300;i++)
{
       scanf("%d%c",&a[i-1],&b);
       if(b=='\n')
       break;
}
max=a[0];min=a[0];
for(j=0;j<=i-1;j++)
{
                   if(a[j]>=max)
                   max=a[j];
                   if(a[j]<min)
                   min=a[j];
}

second=max;
for(j=0,kai=0;j<=i-1;j++)
{
                   if(a[j]<max&&a[j]>=min)
                   {second=a[j];
                   min=second;
                   kai=1;
                  }

}

if(kai==0||i==1)
printf("No");
else
printf("%d",second);

    return 0;
}


int main()
{
	int a[1000],i,t,num,j,k;
	int max(int a,int b);
    int min(int a,int b);
	char c;
//input the sequence
	for(i=1;;i++)
	{
		scanf("%d",&a[i-1]);
		scanf("%c",&c);
		if(c=='\n')break;
	}

	num=i;
//???
	for(j=1;j<=num-1;j++)
	{
		for(k=num;k>=j+1;k--)
		{
			t=max(a[k-1],a[k-2]);
			a[k-1]=min(a[k-1],a[k-2]);
			a[k-2]=t;
		}
	}
//find the sec_max
	for(i=1;i<=num-1;i++)
	{
		if(a[i-1]!=a[i])
		break;
	}
    if(i<num-1)printf("%d",a[i]);
    else
	{
		if(i==num-1)printf("%d",a[i]);
		else printf("No");
	}
	return 0;
}

//the function to find the larger and the smaller

int max(int a,int b)
{
	int e;
	if(a<b)e=b;
	else e=a;
	return e;
}

int min(int a,int b)
{
	int e;
	if(a>b)e=b;
	else e=a;
	return e;
}


int main()
{
	int n,a=0,b=0;
	while(scanf("%d,",&n)!=EOF)
	{
                                 if(n>a)
                                 {b=a;a=n;}
                                 else if(n<a)
                                 if(n>b)
                                 b=n;
                                 }
   if(b==0)
   printf("No");
   else printf("%d",b);
}


int main()

{
	int i=0;
	char fuhao;
	int j,k,number=0;
	int same=0;
	int a[300]={0};
	do
	{
	scanf("%d%c",&a[i],&fuhao);
	i++;
	}
	while (fuhao!='\n');
    for(j=0;j<=i-1;j++)
	{
		for(k=0;k<=i-1;k++)
		{
			if(a[k]==a[j]&&k!=j)
			{
				a[k]=0;
			same++;
			}

		}
		if(same==i-1) goto result;
	}

	for(j=0;j<=i-1;j++)
	{
		for (k=0;k<=i-1;k++)
		{
			if(a[k]>a[j])
			{
				number=number+1;

			}
		}
		if(number==1) goto result;
		number=0;

	}

result: if(number==1) printf("%d",a[j]);

		else  printf("No");

	return 0;
}


int a[10000];
int main()
{
	int m=-999,n=-999,t;
    char c;
    do{
		scanf("%d",&t);
        if(t>m)n=m,m=t;
        else if(t<m&&t>n)n=t;
        c=getchar();
	}while(c>=32);
    if(n==-999)
	printf("No\n");
	else printf("%d\n",n);
	return 0;
}


void main()
{
int a[300];
int i,j,x,temp,count,max;
char c;
for(i=0;i<300;i++)
{
	scanf("%d%c",&a[i],&c);
	if(c=='\n')
	{
		count=i;
		break;
	}
}
for(x=1;x<=count;x++)
{
    for(i=0;i<count+1-x;i++)
	{
         if(a[i]<a[i+1])
		 {
	      temp=a[i];
		  a[i]=a[i+1];
		  a[i+1]=temp;
		 }
	}
}
    if(a[count]==a[0])
	{
	printf("No");
	}
	if(a[count]!=a[0])
	{
	   max=a[0];
	   for(j=0;j<=count;j++)
		{
	       if(a[j]==max){;}
		   else {printf("%d",a[j]);break;}
		}
	}
}


void main()
{
	int a[305],i=1,max,submax,j;
	char p;
	while(scanf("%d%c",&a[i],&p)&&p!='\n')
	{
		i++;
	}
	if(i==1)//?????
	{
		printf("No");
	}
	else
	{
		max=a[1];
		submax=0;
		for(j=2;j<=i;j++)
		{
			if(a[j]>max)
			{
				submax=max;
				max=a[j];
			}
			else
			{
				if(a[j]>submax&&a[j]!=max)
				{
					submax=a[j];
				}
			}
		}
		if(submax==0)
		{
			printf("No");
		}
		else
		{
			printf("%d",submax);
		}
	}
}


int main()
{
	int a,b,c,i;
	b=0;
	c=0;
	i=0;
	scanf("%d",&a);
	while(getchar()!=EOF)
	{
		if(a>b)
		{
			c=b;
			b=a;
		}
		else if(a==b)
			b=a;
		else
		{
			if(c<=a)
				c=a;
		}
		scanf("%d",&a);
		i++;
	}
	if(b==c||i==1||c==0)
	printf("\nNo");
	else
		printf("\n%d",c);
	return 0;
}


main()
{
	int a[300],i=0,len,temp,j;
	while(scanf("%d",&a[i++])!=EOF)
	{
		getchar();
	}
	len=i-1;
	if(len==1)
	printf("No");
	else
	{
	for(i=0;i<len-1;i++)
		for(j=i+1;j<len;j++)
			if(a[i]<a[j])
			{
				temp=a[i];
				a[i]=a[j];
				a[j]=temp;
			}
	for(i=1;i<len;i++)
	{
		if(a[i]!=a[0])
		{
			printf("%d",a[i]);
			break;
		}
	}
	if(i==len)
	printf("No");
	}
}


void main()
{
    char str[2000];
	gets(str);
	int l=strlen(str),i,sum[600]={0},num=0;
	for(i=0;i<l;i++)
	{
	    if(str[i]!=',') sum[num]=sum[num]*10+str[i]-'0';
		else num=num+1;
	}
	int max=0,s=0;
	for(i=0;i<=num;i++)
		if(sum[i]>max) max=sum[i];
    for(i=0;i<=num;i++)
		if(sum[i]>s&&sum[i]<max) s=sum[i];
    if(s==0) printf("No");
	else printf("%d",s);
}


main()
{
  int i,max,second,a[301];
  char c;
  i=1;
  max=0;
  second=0;
  do
   { scanf("%d",&a[i]);
     if(a[i]>max)
      { second=max;
        max=a[i];
      }
     else if(a[i]>second&&a[i]<max)
      second=a[i];
     if(scanf("%c",&c)==EOF)break;
     i++;
   }while(c==',');
  if((i==2)||(max==a[1]&&second==0))printf("No");
    else printf("%d",second);

  /*scanf("%d",a[1]);
  i=2;
  max=a[1];
  second=0;
  while(scanf(",%d",&a[i])!=EOF)
   { if(a[i]>max)
      { second=max;
        max=a[i];
      }
     else if(a[i]>second&&a[i]<max)
      second=a[i];
     i++;
   }
  if((i==2)||(max==a[1]&&second==0))printf("NO");
    else printf("%d",second);*/

  return 0;
}


void main()
{
	int a[1000];
	char c;
	char d;
	int n;
	int i,j;
	int flag=-1;
	int big=0;
	int second=0;
	for(i=0;;i++)
	{
		scanf("%d",&a[i]);
		c=getchar();
		if(c!=',')
		{
			break;
		}
	}
	n=i;
	for(i=0;i<=n;i++)
	{
		if(a[i]>big)
		{
			big=a[i];
		}
	}
	for(i=0;i<=n;i++)
	{
		if(a[i]==big)
		{
			a[i]=-1;
		}
	}
	for(i=0;i<=n;i++)
	{
		if(a[i]>flag)
		{
			flag=a[i];
		}
	}
	if(flag!=-1)
	{
		printf("%d",flag);
	}
	else
	{
		printf("No");
	}
}


int main()
{
	static int a[300];
	int i,max=0,cmax=0;
	scanf("%d",&a[0]);
	for(i=1;getchar()==',';i++)
	{
		scanf("%d",&a[i]);
	}

	for(i=0;i<300;i++)
	{
		if(a[i]>max)
			max=a[i];
	}

	for(i=0;i<300;i++)
	{
		if((a[i]!=max)&&(a[i]>cmax))
			cmax=a[i];
	}
	if(cmax==0)
		printf("No\n");
		else
	printf("%d",cmax);
	return 0;
}


int turn(char a[])
{ int sum=0,i;
  for(i=0;a[i]!='\0';i++)
  sum=sum*10+a[i]-'0';
return sum;
}
int main()
{  char str[300][5]={'\0'},c;
   int i,j,num[300],max,nmax,count;
   for(i=0,j=0;(c=getchar())!='\n';j++)
   {if (c==',') {i++;j=-1;}
   else str[i][j]=c;}
   count=i+1;
   for(i=0;i<count;i++)
	   num[i]=turn(str[i]);
   max=num[0];nmax=0;
   for(i=0;i<count-1;i++)
	  { if(num[i+1]>max) {nmax=max;max=num[i+1];}
	   else if((max-num[i+1]<max-nmax)&&max!=num[i+1]) nmax=num[i+1];}
   for(i=0;i<count-1;i++)
	   if(num[i+1]!=num[i]) break;
	   if(i==count-1) printf("No\n");
	   else printf("%d\n",nmax);
	   return 0;
}


void main()
{
	int i,max,mac=-1;
	scanf("%d",&max);
	while(getchar()!='\n')
	{
		scanf("%d",&i);
		if(i>max)
		{
			mac=max;
			max=i;
		}
		else if(i<max&&i>mac)
			mac=i;
	}
		if(mac!=-1&&mac!=max)
			printf("%d",mac);
		else
			printf("No");
}


int checkprime(int x)
{
	int i;
	if (x==2) return 1;
	else
	{
		for (i=2;i<=sqrt(x)+1;i++)
		{
			if (x%i==0) return 0;
		}
		return 1;
	}

}

int zuida(int x,int y)
{
	if (y==1) return 1;
	else
	{
	if (x%y==0) return y;
	else
	{

	return zuida(y,x%y);
	}
	}
}

main ()
{
	int i,j,a[400],n=0,max=0,max1=0;
	char *p,s[1300];
	scanf("%s",s);
	memset(a,0,sizeof(a));
	for (p=s;*p!='\0';p++)
	{
		if (*p==',') n++;
		else
		{
			a[n]=a[n]*10+(*p-'0');
		}
	}

	if (n==0)
		{
		printf("No");return 0;
		}
	for (i=0;i<=n;i++)
	{
		if (a[i]>a[max])
			max=i;
	}

	for (i=0;i<=n;i++)
	{
		if (a[i]<a[max])
			break;
	}
	if (i==(n+1)) {printf("No");return 0;}
	else
	{
		max1=i;
	for (j=i;j<=n;j++)
		{
			if (a[j]==a[max]) continue;
			else
			{
			if (a[j]>a[max1])
				max1=j;
			}
		}
	}

	printf("%d",a[max1]);

	return 0;

}


void main()
{
	unsigned a[300];
	int i=0,m,l,t;
	char c;
	do
	{
		scanf("%d",&a[i]);
		i++;
		c=getchar();
	}while(c!='\n');
	l=i;
	if(l==1)
		printf("No");
	else
	{
	m=0;
	for(i=1;i<l;i++)
		if(a[i]>a[m])
			m=i;
		t=m;
		m=0;
		while(a[m]==a[t])m++;
		for(i=0;i<l;i++)
		if(a[i]<a[t]&&a[i]>a[m])
			m=i;
		if(a[m]==a[t]||m==l)
			printf("No");
		else
			printf("%u\n",a[m]);
	}
}


void main()
{int num[300],n=0,i,j,t,flag=0;
 char c;
 do
{
	scanf("%d",&num[n++]);
}while(c=getchar()!='\n');

 if(n==1) printf("No");
 else
 {	for(i=0;i<n-1;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;
			}

 for(i=1;i<n;i++)
	if(num[i]<num[0])
	{	flag=1;
	    printf("%d",num[i]);
	    break;
	}
 if(flag==0) printf("No");
 }

 }


void main()
{
	int n[300]={0},i,max=0,len,maxn,t=0;
	char c;
	for(i=0;;i++)
	{
		scanf("%d",&n[i]);
		if((c=getchar())=='\n')
		break;
	}
	len=i;
	if(len==0)
		printf("No\n");
	else
	{
		for(i=1;i<=len;i++)
				if(n[0]!=n[i])
					t=1;
		if(t==0)
			printf("No\n");
		else
		{
			for(i=0;i<=len;i++)
				if(max<n[i])
					{max=n[i];maxn=i;}
			for(i=0;i<=len;i++)
				if(i!=maxn)
					if(n[maxn]==n[i])
						n[i]=0;
			n[maxn]=0;
			max=0;
			for(i=0;i<=len;i++)
				if(max<n[i])
					{max=n[i];maxn=i;}
			printf("%d\n",n[maxn]);
		}
	}
}


int main()
{
       int a[300];
       int i=0,n,max,max2;
	   char c=',';
	   while(c==',')
	   {
		   scanf("%d%c",&a[i],&c);
		   i++;
		   }
	   n=i;

			   max=a[0];
		   for(i=0;i<n;i++)
			 if(a[i]>max) max=a[i];
			else continue;
				max2=0;
			for(i=0;i<n;i++)
			if(a[i]<max&&a[i]>max2)
				max2=a[i];
			else continue;
			if(max2>0)
			printf("%d",max2);
			else printf("No");

return 0;
}


int main()
{
	int n,max=0,i,sec=0,a[301];
	char c;
	for(i=0;;i++)
	{
		scanf("%d%c",&a[i],&c);
		if(c!=',')
			break;
	}
	n=i;
	for(i=1;i<=n;i++)
	{
		if(a[i]>a[max])
		{
			sec=a[max];
			max=i;
		}
		else if(a[i]>sec&&a[i]<a[max])
		{
			sec=a[i];
		}
	}
	if(a[max]==sec||sec==0)
	{
		printf("No");
	}
	else
	printf("%d",sec);
	return 0;
}


int main ()
{
    int a,b,max,min,n,s=0;
    char c;
    scanf("%d%c",&a,&c);
    if (c=='\n')
    printf("No");
    else
    {  scanf("%d%c",&b,&c);
    if (a>b)
    {max=a;
    min=b;
    s=1;}
    else if (a<b)
    {max=b;
    min=a;
    s=1;}
    else
    {max=a;
    min=b;
    s=0;}
    for (;c==',';)
    {
             scanf("%d%c",&n,&c);
             if (n!=a||n!=b)
             s=1;
              if (n>min&&n<max)
               min=n;
              else if (n>max)
               {min=max;
               max=n;}
               else if (n<min&&min==max)
               min=n;
    }

    if (s==0)
    printf("No");
    else
    printf("%d",min);}
       return 0;
}


int main() {
	int a, max=0, inf=0;
	char c;
	do {
		scanf("%d", &a);
		scanf("%c", &c);
		if (a>max) {
			inf=max;
			max=a;
		}
		else if (a==max) {}
		else if (a>=inf) {
			inf=a;
		}
	}while (c==',');
	if (max==inf) {
		printf("No");
	}
	else if (inf==0) {
		printf("No");
	}
	else {
		printf("%d", inf);
	}
	return 0;
}


int main()
{
	int swap(int a , int b);
	int a[100]={0},i=0,j=0,num,t;
	char c;
	for(num=0,i=0;c!='\n';)
	{scanf("%d", &a[i]);
		num++;i++;
		c=getchar();}
	if(num!=1)
	{for(i=0;i<num-1;i++)
		for(j=0;j<num-1-i;j++)
			if(a[j]<a[j+1]){t=a[j];a[j]=a[j+1];a[j+1]=t;}

		for(i=0;i<num;i++)
		{if(a[i]!=a[i+1]){printf("%d",a[i+1]);break;}
			else if(a[0]==a[num-1]) {printf("No");break;}}}
			else printf("No");
			return 0;}
	int swap(int a, int b)
	{int t;
		t=a;a=b;b=t;}


void main()
{
	int t,num[200],i=0,j,n;
	do
	{
		scanf("%d",&num[i]);i++;
	}
	while(getchar()!='\n');
	n=i;

	for(j=0;j<n;j++)
		for(i=0;i<n-j;i++)
		{
			if(num[i]<num[i+1])
			{
				t=num[i];
				num[i]=num[i+1];
				num[i+1]=t;
			}
		}
	t=num[0];
	for(i=0;i<n;i++)
	{
		if(num[i]<t) break;
	}
	if(i==n) puts("No");
	if(i<n) printf("%d",num[i]);
}


int cmp(const void*a,const void*b)
{
	return( 0-*(int*)a+*(int*)b);
}

void main()
{
	int i=0,j,k,n,a[300]={0},max;
	char t;
	while((t=getchar())!=EOF)
	{
		if(t<='9'&&t>='0')
		a[i]=10*a[i]+t-'0';
		else
		i++;
	}
	qsort(a,i+1,sizeof(int),cmp);
	max=a[0];
	for(j=0;j<i+3;j++)
	{
		if(a[j]==0)
		{
			printf("No");
			break;
		}
		else if(a[j]!=max)
		{
			printf("%d",a[j]);
			break;
		}
	}

}


int main()
{
    char c[1501]={' '};
	int i=0,j=0,k=0,l,m,n,max=-1,cmx=-1,tp=0;
	scanf("%s",c);
	l=strlen(c);
	i=l-1;
	while (i>0)
	{if (c[i]!=',') {tp=tp+(c[i]-'0')*pow(10,k);k++;}
	 else
	 {if (tp>=max) {if (tp>max) cmx=max;max=tp;}
	  else if (tp>cmx) cmx=tp;
	  tp=0;k=0;
	 }
	 i--;
	}
    tp=tp+(c[0]-'0')*pow(10,k);
	if (tp>=max) {if (tp>max) cmx=max;max=tp;}
	else if (tp>cmx) cmx=tp;
	tp=0;k=0;
	if (cmx==-1) printf("No");
	else printf("%d",cmx);
	return 7;
}


int main()
{
   int m,i,max,second=0;
   scanf("%d",&m);
   max=m;
   i=0;
   while(i<300)
   {
                      scanf(",%d",&m);
                      if(m>max){
                      second=max;
                      max=m;}
                      else if(m<max&&m>second)
                      second=m;
					  i=i+1;
   }
   if(second==0)
   printf("No");
   else
   printf("%d\n",second);
   return 0;
}


int main ()
{   int num[1000];
    char c;
    int n,i,max1,max2;
    n=0;
    while (1)
   {  scanf("%d%c",&num[n],&c);
      n++;
      if(c!=',') break;
   }
   max1=num[0];
   max2=0;
   for(i=0;i<n;i++)
    if(num[i]>max1) max1=num[i];
   for(i=0;i<n;i++)
     if(num[i]>max2&&num[i]!=max1) max2=num[i];
   if(max2==max1||max2==0) printf("No\n");
   else printf("%d\n",max2);
  return 0;
}


int max(int x,int y)
{
	if(x>y)
		return x;
	else
		return y;
}
int min(int x,int y)
{
	if(x<y)
		return x;
	else
		return y;
}
int main()
{
	int a[300],i=0,t1,t2,t,k;
	char s[300];
	scanf("%d",&a[0]);
	scanf("%c",&s[0]);
	t1=a[0];
	t2=a[0];
	if(s[0]==',')
	{
		i=1;
		do
		{
			scanf("%d",&a[i]);
			scanf("%c",&s[i]);
			if(a[i]==t1||a[i]==t2)
			{
				i++;
				continue;
			}
			else
			{
				t=t1;
				k=a[i];
			    t1=max(t,k);
				if(t1==t2)
					t2=min(t,k);
				else
					t2=max(t2,min(t,k));
				i++;
			}
		}while(s[i-1]==',');
		if(t1==t2)
			printf("No");
		else
			printf("%d",t2);
	}
	else
		printf("No");
    return 0;
}


void main()
{
	char k;
	unsigned a,b,x,i,t;
	scanf("%d",&a);
	b=a;
	for(i=1;i<300;i++)
	{if((k=getchar())!=',') break;
	scanf("%d",&x);
	if(x>a) {b=a;a=x;}
	if(x>b&x<a) b=x;
	if(a==b&x<b) b=x;
	}
	if(a==b) printf("No");
	else printf("%d",b);
}


void main()
{
    int max(int x,int y);
	int a[100];
	int m=0,x=0,j,i=1;
	scanf("%d",&a[1]);
	while(getchar()==',')
	{
		i++;
        scanf("%d",&a[i]);
	}
    if(i!=1)
	{
		for(j=1;j<=i;j++)
			m=max(m,a[j]);
		for(j=1;j<=i;j++)
		{
			if(a[j]==m)
				a[j]=0;
		}
		for(j=1;j<=i;j++)
			x=max(x,a[j]);
		if(x!=0)
			printf("%d\n",x);
		else
			printf("No\n");
	}
	else printf("No\n");
}
int max(int x,int y)
{
	int z;
    if(x>y)z=x;
	else z=y;
	return z;
}


int main(int argc, char *argv[])
{
    int ary[100];  char comma;
    int i,j,k;     int max,sec, count ;
    scanf("%d", &ary[0]); i=1;
    while(scanf("%c", &comma)!=EOF){
           scanf("%d",&ary[i]);
           i++;
    }
    count =i-1;
    max= ary[0];              sec= -1;
    for(j=0; j<count ;j++){
             if(ary[j] > max){
                      sec= max;
                      max= ary[j];
             }
             else if(ary[j] == max){
                  max= ary[j];
             }
             else if(ary[j] > sec){
                  sec= ary[j];
             }

    }
    if(sec != -1){

           cout << sec  ;
    }
    else {
         cout <<"No";
    }

    return EXIT_SUCCESS;
}


int main()
{
    int a,b,k;
    char i;
    scanf("%d",&a);
    b=-1;
    while((i=getchar())==',')
    {
      scanf("%d",&k);
      if(k>a)
      {
      b=a;
      a=k;
      }
      if(k>b&&k<a)
      b=k;
      }
      if(a==b||b==-1)
      printf("No");
      else
      printf("%d",b);
      return 0;
}


int main()
{
	int a[300]={0},i=0,t=0,fir=0,sec=0;
	char c;
	while((c=getchar())!='\n')
	{
		if(c==',') i++;
		else
		{
			a[i]*=10;
			a[i]+=(c-'0');
		}
	}
	t=i+1;
	fir=a[0];
	if(t==1) printf("No");
	else
	{
		for(i=1;i<t;i++)
		{
			if(a[i]>fir)
			{sec=fir;fir=a[i];}
			else if(a[i]<fir&&a[i]>sec)
			sec=a[i];
		}
		if(sec==0) printf("No");
		else printf("%d",sec);
	}
	return 0;
}


int main()
{
  int a[300],n,i,j,t,k;
  scanf("%d",&a[0]);
  for(i=1;;i++)
  {
    if(getchar()==',')
    scanf("%d",&a[i]);
    else
    break;
  }
 for(j=0,t=0;j<i;j++)
{
  if(a[j]>t)
  t=a[j];
}
for(j=0,k=0;j<i;j++)
{
   if(a[j]==t)
   continue;
   else if(a[j]>k)
   k=a[j];
 }
if(k==0)
printf("No");
else
printf("%d",k);
return 0;
}


int main()
{
	int a,max=0,maxi=0,p=0,q=0;
	char b;
	scanf("%d",&a);
	b=getchar();
	while(b==',')
	{
		p++;
		if(a>max)
		{
			maxi=max;
			max=a;
		}
		else if(a==max)
			q++;
		else if(a>maxi)
			maxi=a;
		scanf("%d",&a);
		b=getchar();
	}
	p++;
	if(a>max)
	{
		maxi=max;
		max=a;
	}
	else if(a==max)
		q++;
	else if(a>maxi)
		maxi=a;

	if(p==1)
		printf("No");
	else if(p==(q+1))
		printf("No");
	else
	    printf("%d",maxi);
	return 0;
}


void main()
{
	int max,sec=-1,temp;
	scanf("%d",&temp);
	getchar();
	max=temp;
	while(scanf("%d",&temp)!=EOF)
	{
		getchar();
		//if(temp==0) break;
		if(temp>max)
		{
			sec=max;
			max=temp;
			continue;
		}
		else if(temp<max && temp>=sec) sec=temp;
	}
	if(sec==max || sec==-1) printf("No\n");
	else printf("%d\n",sec);

}


void main()
{
   char c;
   int value=0,i=0,max,next=-1,k,n,a[300]={0};
   while((c=getchar())!='\n')
   {
    if(c==',')
     {a[i]=value;i=i+1;value=0;}
    else value=value*10+c-'0';
   }
   a[i]=value;i=i+1;
   max=a[0];
   k=1;
   n=i;
   while(k<n)
   {
     if(a[k]>max)
      {next=max; max=a[k];}
     else
     if((a[k]<max)&&(a[k]>next))
     next=a[k];
     k++;
    }
     if(next!=-1)
     printf("%d",next);
     else printf("No");
}


int main()
{
	int a[301],i,n,max,second=-1;
	char c;
	for(i=1;i<=300;i++)
	{
		scanf("%d%c",&a[i],&c);
		if(c=='\n') break;
	}
	n=i;
	max=a[1];
	for(i=2;i<=n;i++)
	{
		if(max<a[i])
		{
			second=max;
			max=a[i];
		}
		else if(second<a[i]&&a[i]<max)
		{
			second=a[i];
		}
	}
	if(n==1||second==-1)
		printf("No\n");
	else printf("%d\n",second);
	return 0;
}


int MAX(int a[],int k)
{	int i,j,max=0;
	for(i=0;i<k;i++)
	{if(a[i]>max)
	{j=i;max=a[i];
	}
	}
	return(max);
}
int nexttomax(int a[],int k,int m)
{	int i,j,max=0;
	for(i=0;i<k;i++)
	{if((a[i]>max)&&(a[i]!=m))
	{j=i;max=a[i];
	}
	}
	return(max);
}
int check(int x)
{	int i,p=1;
	for(i=2;i<x;i++)
		if(x%i==0)
		{p=0;break;
		}
	return(p);
}
int checkstr(int a[],int k)
{	int i,p=0;
	for(i=1;i<k;i++)
	if(a[i]!=a[0])
	{p=1;break;}
	return(p);
}
int tongji(char str[])
{	int i=0,count=0;
	while(str[i]!='\0')
	{if(str[i]==',') count++;
	i++;
	}
	return(count);
}
int convertor(char str[],int start,int end)
{	int i,r=str[start]-'0';
	for(i=start+1;i<end;i++)
	r=r*10+(str[i]-'0');
	return(r);
}
void main()
{	int i,j=0,k=0,n,flag=1,fw;
	char str[N];
	int num[300];
	gets(str);
	n=tongji(str)+1;
	if(n==1) printf("No");
	else
	{for(i=0;i<strlen(str);i++)
	if(str[i]==',')
		{num[k++]=convertor(str,j,i);
		j=i+1;
		}
		num[k++]=convertor(str,j,i);
	if(checkstr(num,k)==0&&n!=1) printf("No");
	else
	{fw=MAX(num,k);
	printf("%d",nexttomax(num,k,fw));
	}
	}
}


int main()
{
	int i=1,n,m,num[300],sub,flag=0;
	scanf("%d",&num[0]);
	while(scanf(",%d",&num[i]))
	{
		i++;
	}
	n=i;
	m=num[0];
	for(i=1;i<n;i++)
	{
		if(m<num[i]) m=num[i];
		flag=1;
	}
	if(flag==0) {printf("No");return 0;}
	sub=0;
	for(i=0;i<n;i++)
	{
		if(num[i]==m) continue;
		if((sub<num[i])) sub=num[i];
	}

	if(sub!=0) printf("%d",sub);
	else printf("No");
	return 0;
}


void main()
{
	int a[301],i,max,max2=0;
	char c;
	scanf ("%d",&a[0]);
	max=a[0];
	for (i=1;;i++)
	{
		c=getchar();
		if (c=='\n')
			break;
		scanf("%d",&a[i]);
		if (a[i]>=max)
		{
			if (a[i]>max)
			{
				max2=max;
				max=a[i];
			}
		}
		else
		{
			if (a[i]>=max2)
				max2=a[i];
		}
	}
	if (i==1 || max2==0)
		printf("No\n");
	else
		printf("%d\n",max2);
}


main()
{
	int a[301],n=0,i,k=1,max,sub=0,t;
	char c;
	while((c=getchar())!='\n')
	{
		if(c>='0'&&c<='9')
		{
			n=n*10+c-'0';
		}
		else
		{
			a[k]=n;
			k++;
			n=0;
		}
	}
	a[k]=n;
	if(k!=1)
	{
		max=a[1];
		for(i=2;i<=k;i++)
		{
			if(a[i]!=max)
			{
				sub=a[i];
				break;
			}
		}
		if(sub==0)
			printf("No\n");
		else
		{
			if(sub>=max)
			{
				t=sub;
				sub=max;
				max=t;
			}
			for(;i<=k;i++)
			{
				if(a[i]>max)
				{
					sub=max;
					max=a[i];
				}
				else
				{
					if(a[i]==max)
						continue;
					else
					{
						if(a[i]>sub)
			         	 sub=a[i];
					}
				}
			}
			printf("%d\n",sub);
		}
	}
	else
		printf("No\n");
	return 0;
}


int main()
{
	int a, max, sec=-1, i;
	char s;
	scanf("%d", &max);
	for(i=0;i<300;i++)
	{
		scanf("%c", &s);
		if(s=='\n') break;
		scanf("%d", &a);
		if(a>max){sec=max;max=a;}
		else if(a==max) continue;
		else
		{
		    if(a>sec)
		   {
			 sec=a;
		   }
		}
	}
	if(sec==-1)
	{
		printf("No");
	}
	else if(max==sec)
	{
		printf("No");
	}
	else
	{
		printf("%d", sec);
	}
	return 0;
}


int max(int num[],int n)
{
	int result,i;
	result=num[0];
	for(i=1;i<n;i++)
	{
		if(num[i]>result)
			result=num[i];
	}
	return(result);
}
void main(void)
{
	int n,num[300],i,m1,m2;
	char c;
	for(i=0;i<300;i++)
		num[i]=-1;
	scanf("%d",&num[0]);
	n=1;
	for(i=1;i<300&&(c=getchar())!='\n';i++)
	{
		scanf("%d",&num[i]);
		n++;
	}
	m1=max(num,n);
	for(i=0;i<n;i++)
	{
		if(num[i]==m1)
			num[i]=-1;
	}
	m2=max(num,n);
	if(m2!=-1)printf("%d\n",m2);
	else printf("No\n");
}


int sort(int in[],int n)
{
	int i=0,t=0,j=0;
	for(i=0;i<n;i++)
	{
		if(in[i]>t)
		{
		t=in[i];
		j=i;
		}
	}
	return j;
}
int change(int in[],int n,int j)
{
	int a=0,i=0;
	a=in[j];
	in[j]=0;
	i=sort(in,n);
	if(a==in[i])
		return change(in,n,i);
	else
		return i;
}
void main()
{
	int i=0,n=0,a=0,in[300],j=0,s=0;
	char c;
while(scanf("%d,",&in[i],c)!=EOF)
{i++;n++;}
	if(n==1)
		printf("No");
	else
	{
		j=sort(in,n);
	s=change(in,n,j);
		if(in[s]==0)
			printf("No");
		else
		printf("%d",in[s]);
	}
}


void main()
{
	int flag=0,counter=0,a[300],i=0,j,t;
	char c;
	scanf("%d",&a[i]);i++;counter++;
	while( (c=getchar())==',')
	{scanf("%d",&a[i]);
	 if (a[i]!=a[0]) flag=1;
		i++;counter++;}
    if(counter==1||flag==0) printf("No");
	else
	{
		for(j=0;j<counter-1;j++)
		{	for(i=0;i<counter-1-j;i++)
				if(a[i]>a[i+1])
				{t=a[i];a[i]=a[i+1];a[i+1]=t;}
		}
	    for(j=counter-2;j>=0;j--)
			if(a[j]<a[counter-1])
			{printf("%d",a[j]);break;}
				}
}


int max(int a[],int n)
{
	int i,t,max=0;
	for(i=0;i<=n-1;i++)
		if(a[i]>max)
		{t=i;max=a[i];}
	return(t);
}
void main()
{
	int a[300],i,n,m,t,k;
	char c;
    scanf("%d",&a[0]);
	for(i=1;;i++)
	{
		if((c=getchar())!=',') break;
		else scanf("%d",&a[i]);
	}
	n=i;
	if(n==1) printf("No");
	else
	{
        t=max(a,n);
		m=a[t];a[t]=0;
		for(k=1;k<=n-1;k++)
		{
			if(a[max(a,n)]==m)
			{
				if(k==n-1) printf("No");
				a[max(a,n)]=0;
			}
			else
			{printf("%d",a[max(a,n)]);break;}
		}
	}
}


int main()
{
	int n,i,a[300],max=0,secondmax=0;
	char c;
	for(n=0;1;n++)
	{
		scanf("%d%c",&a[n],&c);
		if(a[n]>max)
		{
			secondmax=max;
			max=a[n];
		}
		if(a[n]>secondmax&&a[n]<max)
		{
			secondmax=a[n];
		}
		if(c=='\n')
			break;						//continue????????????????break????
	}
	if(secondmax==0)
		printf("No\n");
	else
		printf("%d\n",secondmax);
	return 0;
}


int main()
{
	int second(int a[],int n);
	int k=0,a[300],num=0;
	char c;
	do
	{
		scanf("%d%c",&a[k++],&c);
		num++;
	}
	while(c!='\n');
	if(second(a,num)!=-1)printf("%d",second(a,num));
	else printf("No");
	return 0;
}
int second(int a[],int n)
{
	int max=a[0],k=1,next=-1;
	while(k<n)
	{
		if(a[k]>max)
		{
			next=max;
			max=a[k];
		}
		if(a[k]<max&&a[k]>next) next=a[k];
		k++;
	}
	if(next!=-1) return next;
	else return(-1);
}