int main()
{
	int n,a,b,c,d;
	scanf("%d",&n);
	scanf("%d",&a);
	scanf("%d",&b);
	n=n-2;
	if(b>a)
	{
		c=b;
		b=a;
		a=c;
	}
	do
	{
		n--;
		scanf("%d",&d);
		if(d>b)
		{
			c=d;
			d=b;
			b=c;
		}
		if(b>a)
		{
			c=b;
			b=a;
			a=c;
		}
	}
	while(n!=0);
	printf("%d\n%d",a,b);
	return 0;
}


int main()

{
	int k[100];
	int n=0;
	int i=0;
	int Max=0;
	int Max2=0;
	cin>>n;
	for (i=0;i<n;i++)
	{cin>>k[i];
	}
	for(i=0;i<n;i++)
	{if(k[i]>Max)
	Max=k[i];}
	for(i=0;i<n;i++)
	{if(k[i]<Max&&k[i]>Max2)
	Max2=k[i];}
	cout<<Max<<endl;
	cout<<Max2<<endl;
	return 0;

}


int main()
{
	int count,max1,max2,i,a,b,c;
	scanf("%d\n",&count);
	scanf("%d%d",&b,&c);
	if(b>c)
		max1=b,max2=c;
	else if(b<c) max1=c,max2=b;
	else max1=max2=b=c;

	for(i=1;i<=count-2;i++)
	{
		scanf("%d",&a);
		if(a>max1)
		{
			max2=max1;
			max1 = a;
		}
		else if(max2<a && a<max1)
			max2 =a;
		else
		{
			max1=max1;
			max2=max2;
		}
	}
	printf("%d\n%d",max1,max2);
	return 0;
}


int main()
{
	int i=0;
	int a;
	int b;
	int max=0;
	int smax=0;
	scanf("%d",&a);
	for(i=0;i<a;i++)
	{
		scanf("%d",&b);
		if(b>max)
		{
			smax=max;
			max=b;
		}
		else if(b>smax)
		{
			smax=b;
		}
		else
		{
			;
		}
	}
	printf("%d\n",max);
	printf("%d",smax);
	return 0;
}


int main()
{
	int a;
	scanf("%d",&a);
	int i,b,t,x,y;
	for(i=1;i<=a;i++)
	{
		scanf("\n%d",&b);
		if(b>=t)
		{
			x=t;
			t=b;
		}
		else
		{
			if(b>=x)
		    x=b;
		}
	}
	printf("%d\n%d",t,x);
	return 0;
}


int main()
{
	int n,x[100],i,max,max2;
	cin>>n;
	max=0;max2=0;
	for(i=0;i<n;i++)
		cin>>x[i];
	for(i=0;i<n;i++)
		if(x[i]>max)
			max=x[i];
	for(i=0;i<n;i++)
		if(x[i]>max2)
			if(x[i]!=max)
			max2=x[i];

		cout<<max<<endl<<max2<<endl;
		return 0;
}


int main(int argc, char* argv[])
{
    int n,i,num[100],max=0,max2=0,e;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&num[i]);
		if(num[i]>max&&num[i]>max2){
			e=max;
			max=num[i];
            max2=e;
		}else if(num[i]>max2){max2=num[i];}

	}

	printf("%d\n%d\n",max,max2);
	return 0;
}


int main()
{
	int n,a,b,c,d,e;
	scanf("%d\n",&n);
	scanf("%d\n",&a);
	scanf("%d\n",&b);
	if(a>=b)
	{
		c=a;
		d=b;
	}
	else
	{
		c=b;
		d=a;
	}
	for(int i=0;i<n-2;i++)
	{
		scanf("%d\n",&e);
		if(e>=c)
		{
			d=c;
			c=e;}
		else if(e<c&&e>=d)
			d=e;
	}
	printf("%d\n%d\n",c,d);
	return 0;
}


int main()
{

	int s, x, i,n,t;
	scanf("%d", &n);
	s=0;
	for(i=0; i<n; i++) {
		scanf("%d", &x);
	if (x>=s)
               {
		       t=s;
               s=x;
		}
        else if (x>t)
        {
			t=x;
        }
	}
	printf("%d\n", s);
	printf("%d", t);
		return 0;
}


int main(){
int max1,max2,num,n;
int i=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{scanf("%d",&num);
if(i==0){max1=num;}
		else if(i==1)
	{
		if(num>max1){max2=max1;
		max1=num;}
		else max2=num;
	}
	    else if(i>1)
		{if(num>max1){max2=max1;
		max1=num;}
		 else if(num>max2)max2=num;
		}
}
printf("%d\n%d\n",max1,max2);
return 0;}


int main()
{
	int a[100];
	int i,j,max=a[0],lmax=a[1],n,t;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("\n%d",&a[i]);
		if(a[i]>max) max=a[i];
	}

	for(j=0;j<n;j++)
	{
		if(a[j]>lmax&&a[j]<max) lmax=a[j];
	}
	printf("%d\n%d",max,lmax);
	return 0;
}


void main()
{
	int n,i=0,a[10000],max=0,may=0;
	scanf("%d",&n);
	while(i<n)
	{
		scanf("%d",&a[i]);
		if(a[i]>max)
			max=a[i];
		else if(a[i]>may)
			may=a[i];
		i++;
	}
	if(a[0]>may&&a[0]<max)
		may=a[0];
	printf("%d\n%d\n",max,may);
}


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


int main()
{
	int n,a,b,c,i;
	scanf("%d\n",&n);
	scanf("%d",&a);
	scanf("%d",&b);
	while(n-2)
	{scanf("%d",&c);
	if(b>a) {if(a>c) {i=b;b=a;a=i;}
	          else {if(b>c) {a=b;b=c;}
			       else a=c;} }
    else {if(b<c) {if(a<c) {b=a;a=c;}
	               else b=c;}}
         n=n-1;
	}
	printf("%d\n",a);
	printf("%d",b);
	return 0;
}


int main()
{
int i,n,a,b,c,d;
scanf("%d",&n);
scanf("%d",&a);
b=a;
d=a;
for(i=1;i<n;i++)
{
	scanf("%d",&a);
	if(a>b){b=a;}
	else{
		if(a>d){d=a;}
	}
}

printf("%d\n%d",b,d);
return 0;
}


int main()
{
	int i,j,k;
	int n;
	scanf("%d",&n);
	int list[n];

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

	for (j=n-2;j>=n-3;j--) {
		for (k=0;k<=j;k++) {
			if (list[k] > list[k+1]) {
				list[k]=list[k]+list[k+1];
				list[k+1]=list[k]-list[k+1];
				list[k]=list[k]-list[k+1];
			}
		}
	}
	printf("%d\n%d",list[n-1],list[n-2]);

	return 0;
}


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


int main()
{
	 int n;
	 scanf("%d\n",&n);
     int a,i,sum,som;
     for(i=0;i<n;i++){
         scanf("%d\n",&a);
		 if(i==0){
			 sum=a;
			 som=0;
		 }else if(sum<a){
				som=sum;
                                     sum=a;
		 }else if(som<a){
				 sum=sum;
				 som=a;
		 }else if(som>a){
				 sum=sum;
				 som=som;
		 }
	 }
		 printf("%d\n%d\n",sum,som);
		 return 0;
}


int main()
{
	int n;
	int first,second;
	int x,i;
	scanf("%d\n",&n);
	if(n>1&&n<100)
	{
		if(n==1)
		{
			int a;
			scanf("%d",&a);
			first = second=a;
		}
		else{
			for(i=0;i<n;i++)
			{
		       scanf("%d",&x);
				if(i==0)
				{
					first=x;
					second=0;
				}
				else
				{
					if(first<x)
					{
						second=first;
						first=x;
					}
				    else if(second<x)
					{
					    first=first;
					    second=x;
					}
				}

			}
		}
		printf("%d\n%d",first,second);
	}
return 0;
}


int main(int argc, char* argv[])
{
	int n;
	int i,j,k;
	int a[100];
	int max,cimax;
	scanf("%d\n",&n);
	for(i=0;i<n;i++)
	{
	   scanf("%d",&a[i]);
	}
	max=0;
	cimax=0;
	for(j=0;j<n;j++)
	{
	   if(a[j]>max)
	   {
	      max=a[j];
	   }
	}
    printf("%d\n",max);
	for(k=0;k<n;k++)
	{
	   if(a[k]>cimax && a[k]!=max)
	   {
	      cimax=a[k];
	   }
	}
	printf("%d\n",cimax);
	return 0;
}


int main()
{
	int an[100];
	int a,b,M,m,n,i;
	scanf("%d",&n);
	scanf("%d\n%d",&a,&b);
	if(a>=b){
		M=a;
		m=b;
	}
	else{
		m=a;
		M=b;
	}
	for(i=2;i<n;i++){
		scanf("%d\n",&an[i]);
		if(an[i]>M){
			m=M;
			M=an[i];
		}
		else if(an[i]<M && an[i]>m){
			m=an[i];
		}
	}
	printf("%d\n%d",M,m);
	return 0;
}


int main (){
	int a;
	scanf("%d",&a);
	int b,c,d,e,n;
	n=2;
	while(n<=a){
		if(n==2)
		{
			scanf("%d %d",&d,&e);
			if(d>=e){
				b=d;
				c=e;
			}
			else{b=e;
			c=d;}
		}
		else{
			scanf("%d",&d);
			if(d>=b){
				c=b;
				b=d;
			}
			else if (d>=c){
				c=d;}
		}
	n++;
	}
	printf("%d\n%d\n",b,c);
	return 0;
}


int main()
{
int n;
scanf("%d",&n);
 int num[n],temp;
 int i=0;

 while(i<n)
 {
  scanf("%d",&num[i]);
  i++;
 }
 for(int x=0;x<n-1;x++)
 {
  for(int y=n-1;y>x;y--)
  {
   if(num[y]>num[y-1])
   {
    temp=num[y];
    num[y]=num[y-1];
    num[y-1]=temp;
   }
  }
 }
 printf("%d\n%d\n",num[0],num[1]);
return 0;
}


int main()
{
   int a[100],n,i,max,sec;
   cin>>n;
   for(i=0;i<n;i++)
   { cin>>a[i];}
   max=a[0];
   sec=a[0];
   for(i=1;i<n;i++)
   {
     if(a[i]>max) max=a[i];
     else if (a[i]>sec) sec=a[i];
    }
    cout<<max<<endl<<sec<<endl;
   return 0;
}


int main()
{
	int A[100 + 10], N;
	cin >> N;
	for (int i = 0; i < N; i ++)
		cin >> A[i];
	sort(A, A + N);
	cout << A[N - 1] << endl << A[N - 2] << endl;
	return 0;
}


void main()
{
 int a[100],i,max=0,smax=0,n;
 scanf("%d",&n);
 for (i=0;i<n;i++)
  scanf("%d",&a[i]);
 for (i=0;i<n;i++)
  {
    if(a[i]>max)
     max=a[i];
  }
 for (i=0;i<n;i++)
  {
    if((a[i]>smax)&&(a[i]!=max))
      smax=a[i];
   }
 printf("%d\n",max);
 printf("%d\n",smax);
}


int main()
{
    int i;
    scanf("%d",&i);
    int a,max=0,sec=0;
    while(i>0&&i<100)
    {
       scanf("%d",&a);
       if(a>=max)
       {sec=max;
       max=a;}
       if(a<max&&a>sec)
       sec=a;
       i--;
    }
printf("%d\n",max);
printf("%d\n",sec);
return 0;
}


int main(){
	int max=0,mbx=0,i,x;
	scanf("%d\n",&i);
	while(i>=0){
		scanf("%d\n",&x);
		i--;
		if(i>=0){
			if(max>x&&mbx<x)mbx=x;
			else if(mbx>x)
				;
			else if(max<x){
				mbx=max;
				max=x;
			}
		}
	}
		printf("%d\n%d\n",max,mbx);
	return 0;
}


int main()
{
  int x,max,secondmax,n,t,i;
  scanf("%d %d",&n,&x);
  secondmax=max=x;
	  for(i=1;i<n;i++)
	  {
		  scanf("%d",&t);
		  if(t>max)
		  {
			  secondmax=max;
			  max=t;
		  }
		  else if(t>secondmax)
		  {
			  secondmax=t;
		  }
		  else if((max==secondmax)&&(i==1))
		  {
			  t=secondmax;
		  }
	  }
   printf("%d\n%d\n",max,secondmax);
   return 0;
}


int main()
{
 int n,i=3,a,b,x;
 scanf("%d%d%d",&n,&a,&b);

 while(i<=n)
 {
   scanf("%d",&x);

   if((a<x)&&(x<b))
   {
	   a=x;
   }
   else if(x>b)b=x;

   i++;

 }
 if(a<b)
 printf("%d\n%d",b,a);
 else printf("%d\n%d",a,b);
 return 0;
}


void main()
{
	int n,i,a,b,max,sub,temp;
	scanf("%d %d",&n,&a);
max=a;sub=a;
for(i=1;i<=(n-1);i++)
{
	scanf("%d",&b);
	if(max<b)
	{temp=max;max=b;sub=temp;}
	if(sub<b&&b<max)
		sub=b;}
	printf("%d\n%d",max,sub);
}


int main()
{
 int i=0;
 int n,tmp=0;
 int a=0,b=0;
 scanf("%d",&n);

 for(i=0;i<n;i++)
 {
   scanf("%d",&tmp);
   if (tmp>a)
   {
     b=a;
     a=tmp;
   }
   else
   {
     if (tmp>b)
       b=tmp;
   }
 }

printf("%d\n",a);
printf("%d",b);
	return 0;
}


int main(int argc, char *argv[])
{
    int a,b;
    a=b=0;
    int num;
    cin >> num;
    int i;
    int keyin;
    for(i=1;i<=num;i++)
    {
          cin >> keyin;
          if(keyin >= a)
          {
                   b =a;
                   a= keyin;
          }
          else if(keyin >b)
          {
               b= keyin;
          }
    }
    cout << a <<endl;
    cout << b;

    return EXIT_SUCCESS;
}


void main()
{
 int number, largest, second, counter,n;
 counter = 1;

 scanf("%d",&n);
 largest=-10000000; second=largest;
 while ( counter <= n )
 {

  scanf ( "%d", &number );

  if ( number >= largest )
  {
      second  = largest;
      largest = number;
  }
  else if (second< number&&number < largest)
   second =number;
  else if(number<= second)
	  second=second;

  counter++;
 }
 printf ( "%d\n", largest );
 printf ( "%d\n", second);
}


int main()
{
	int n,a[101],i,max,second;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		{scanf("%d",&a[i]);}
	if(a[1]>a[2])
		{max=a[1];
		second=a[2];}
	else
		max=a[2];
		second=a[1];
	if(n<=2)
		{printf("%d\n",max);
		printf("%d\n",second);}
	else
	{	for(i=3;i<=n;i++)
		{	if(a[i]>max)
			{second=max;
			max=a[i];}
			else if(max>a[i]&&second<a[i])
				second=a[i];
		}
		printf("%d\n",max);
		printf("%d\n",second);}
	return 0;
}


void main()
{
	int a,b,c,n,i;
	float d,e;
	scanf("%d",&n);
	scanf("%d",&a);
	scanf("%d",&b);
	for(i=1;i<=(n-2);i++)
	{
		scanf("%d",&c);
		d=(float)(a+b)/2;
		e=(float)(a-b)/2;
		if(c>=a)
		{
			if(c>=b)
			{a=c;
			b=d-e;
			c=d+e;
			}
		else {a=d-e;
			b=d+e;
			c=c;
			}
		}
			else
			{if(a<=b)
				{a=d-e;
				b=d+e;
				c=c;}
			else {a=d+e;
				b=d-e;
				c=c;
				}
			}
		if(b>=c)b=b;
		else b=c;
	}
	printf("%d\n%d",a,b);
}


void main()
{
	int n,a,i,b,c,max1,max2;
	scanf("%d",&n);
	i=1;
    scanf("%d",&a);
    scanf("%d",&b);
	if(a<b)
	{
		max1=b;
		max2=a;
	}
	else if(a>b)
	{
		max1=b;
		max2=a;
	}

	while(i<=(n-2))
	{
		scanf("%d",&c);
		if(c>=max2&&c<max1)
		{
			max2=c;
			max1=max1;
		}
		else if(c<max2)
		{
			max2=max2;
			max1=max1;
		}
		else if(c>=max1)
		{
			max2=max2;
			max1=c;
		}
		i++;
	}
	printf("%d\n",max1);
	printf("%d",max2);
}


int main()
{
	int i, n, a[200], max, submax;
	scanf("%d", &n);
	for (i=0; i<n; i++)
		scanf("%d", &a[i]);
	max = submax = -32321;
	for (i=0; i<n; i++)
		if (a[i] > max) {
			submax = max;
			max = a[i];
		} else if (a[i] > submax)
			submax = a[i];

	printf("%d\n%d", max, submax);

	return 0;
}


int compare (const void * a, const void * b)
{
  return ( *(int*)b - *(int*)a );
}

int main(){
	int n;
	cin>>n;
	int a[100];
	for(int i=0;i<n;i++)cin>>a[i];
	qsort(a,n,sizeof(int),compare);
	for(int i=0;i<=1;i++)cout<<a[i]<<endl;
	return 0;
}


int main()
{
	int i,n,j,k[101],l,max,sec=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	   {
		scanf("%d",&k[i]);

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

		{sec=max;
		max=k[i];}
       else if((k[i]<max)&&(k[i]>=sec))
		sec=k[i];

	   }
	 printf("%d\n",max);
	 printf("%d",sec);
	 return 0;

	}


int main()
{int n,a,b,c,i;
scanf("%d\n",&n);
scanf("%d\n%d\n",&a,&b);
if(b>a)
{
c=a;
a=b;
b=c;
}
for(i=1;i<=n-2;i++)
{
scanf("%d\n",&c);
if(c>a)
{b=a;
a=c;}
else if(c>b)
b=c;
}
printf("%d\n%d\n",a,b);
return 0;
}


int main()
{
    int a[1000];
    int max, max2;
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
    }

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

    for(int i=0; i<n; i++){
        if(a[i] != max){
            max2 = a[i];
            break;
        }
    }
    for(int i=0; i<n; i++){
        if((a[i]>max2) && (a[i]!=max)){
            max2 = a[i];
        }
    }

    printf("%d\n%d\n", max, max2);

    return 0;
}


int main()
{
 int max[2]={0};
 int n,number;
 cin>>n;
 for(int i=0;i<n;i++)
 {
  cin>>number;
  if(number>max[0])
  {
   max[1]=max[0];
   max[0]=number;
  }
  else if(number>max[1])
  {
   max[1]=number;
  }
 }
 cout<<max[0]<<endl<<max[1]<<endl;
 return 0;
}


int main(int argc, char *argv[])
{int i,index,k,n,temp;
int a[100];
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(k=0;k<2;k++){
 index=k;
 for(i=k+1;i<n;i++)
 if(a[i]>a[index])  index=i;
 temp=a[index];
 a[index]=a[k];
 a[k]=temp;              }
  printf("%d\n%d\n",a[0],a[1]);

  return 0;
}


void main()
{
	int *p,i,n,max,sec;
	p=(int *)(malloc(10000*sizeof(int)));
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",p+i);
	}
	max=*p;
	sec=*p;
	for(i=1;i<n;i++)
	{
		if(*(p+i)>max) max=*(p+i);
		else if(*(p+i)>sec) sec=*(p+i);
	}
	printf("%d\n%d",max,sec);
}


int main()
{
	int n;
	scanf("%d", &n);
	if(n<=1||n>=100)
	{
		return 0;
	}

	int temp;
	int max, lmax;
	scanf("%d", &max);
	scanf("%d", &lmax);
	if(lmax > max)
	{
		temp=lmax;
		lmax=max;
		max=temp;
	}

	int i=3;
	while(i<=n)
	{
		scanf("%d", &temp);
		if(temp>max)
		{
			lmax=max;
			max=temp;
		}
		else if(temp>lmax)
		{
			lmax=temp;
		}
		i++;
	}
	printf("%d\n", max);
	printf("%d", lmax);
	return 0;
}


int main()
{
	int n,i,x;
	int first,second;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&x);
		if(i==0)
		{
			first=x;
			second=x;
		}
		else if(i==1)
		{
			if(x>first)
			{
				second=first;
				first=x;
			}
			else if(x=first)
			{
				second=x;
				first=x;
			}
		}
		else
		{
			if(x>first)
			{
				second=first;
				first=x;
			}
			else if(x>second)
			{
				second=x;
			}
		}
	}
	printf("%d\n",first);
	printf("%d\n",second);
	return 0;
}


int main()
{
	int n,a,b,i,t;
	scanf("%d%d%d%d",&n,&a,&b,&t);
	if(a>b){
		a = a;
		b = b;
	}
	else
	{
		t = a;
		a = b;
		b = t;
	};

    for(i=3;i<=n;i++)
    {
		int c;
		scanf("%d",&c);
    if(c>a&&c>b)
	{
		t = a;
		a = c;
		b = t;

	}
    else if(c<a&&c>b)
	{
		a = a;
		b = c;
	}
	else {
		a = a;
		b = b;
	};
	};
		printf("%d\n",a);
		printf("%d",b);

	return 0;
}


int main()
{
	int num,len;
	int max1=0,max2=0;
	int tmp,i;
	scanf("%d",&len);
	for (i = 1;i<=len;i++)
	{
		scanf("%d",&num);
		if(num>max1)
		{
			tmp=num;
			num=max1;
			max1=tmp;
			if (num>max2)
			{
				tmp=num;
				num=max2;
				max2=tmp;
			}
		}
		if(max1>num&&num>max2)
		{
			tmp=num;
			num=max2;
			max2=tmp;
		}

	}
	printf("%d\n%d\n",max1,max2);
	return 0;
}


int main()
{
    int n,a=0,b=0,shuzu[111];
    scanf("%d",&n);
    int i,j;
    for(i=0;i<n;i++){
                     scanf("%d",&shuzu[i]);
                     }
    for(i=0;i<n;i++){
                      if(a<shuzu[i]){
                                       a=shuzu[i] ;
                                       }
                                       }
    printf("%d\n",a);
    for(i=0;i<n;i++){
                      if(a==shuzu[i]){
                                          shuzu[i]=0;
                                          }
                                          }
    for(i=0;i<n;i++){
                      if(b<shuzu[i]){
                                      b=shuzu[i] ;
                                      }
                                      }
     printf("%d",b);
     return 0;
     }


int main()
{
	int len,e;
	scanf("%d",&len);
	int num[100];
	scanf("%d\n",&num[0]);
	for(int k=1;k<=2;k++)
	{
		for(int i=0;i<len-k;i++)
		{
			scanf("%d",&num[i+1]);
			if(num[i]>num[i+1])
			{
				e=num[i+1];
				num[i+1]=num[i];
				num[i]=e;
			}
		}
	}
	printf("%d\n%d\n",num[len-1],num[len-2]);
	return 0;
}


int main(){
	int n,i,num,max1,max2,exc;
	i=1;
	max1=0;
	max2=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&num);
		if(i==1){max1=num;}
		else if(i==2){
			if(max1>=num){
				max2=num;
			}else if(num>max1){
				exc=max1;
				max2=exc;
				max1=num;
			}
		}else if(i>=3){
			if(num>max1){
			    exc=max1;
				max2=exc;
				max1=num;
			}else if(num>max2){
				max2=num;
			}
		}
	}
		printf("%d\n%d\n",max1,max2);
		return 0;
	}


int main ()  {
	int result=0,p=0;
	int num,n;
	int i=1;
       scanf("%d", &n);
	while(i<=n&&n<=100){
		scanf("%d", &num);
	      if(i == 1){
			 result = num;
		}
		  else{
		      if(num > result){
			     p=result;
				  result = num; }
			  else if(num<result&&num>p){
				  p=num;}
	      }
		   i++;
	}
	printf("%d\n%d", result,p);
	return 0;
}


int main(){
	int num,max1,max2;
	int n;
	int a;
	int i;
    scanf("%d%d",&n,&num);
	max1= num;
scanf("%d",&num);
		if (num>max1){
		 a=max1;
		 max1=num;
		 max2=a;}
		else{
			max2=num;
			}
       for (i=0;i<n-2;i++){
		scanf("%d",&num);
		if (num>max1){
		 a=max1;
		 max1=num;
	     max2=a;}
	else if (num>max2)
		max2=num;}
    printf("%d\n%d\n",max1,max2);
	return 0;
}


int main()
{
   int n,a,b,c,d,i;
	scanf("%d\n%d\n%d\n",&n,&a,&b);
	if(a<b){
		c=a;
		b=a;
		a=c;
	}
	for(i=3;i<n;i++){
		scanf("%d\n",&d);
		if(d>=a){
			b=a;
			a=d;
		}
		else if(d>=b){
			b=d;
		}
	}
scanf("%d",&d);
		if(d>=a){
			b=a;
			a=d;
		}
		else if(d>=b){
			b=d;
		}
	printf("%d\n%d\n",a,b);
   return 0;
}


void main()
{
	int n,a,max,sec,i,x;
	scanf("%d",&n);
	scanf("%d",&x);
	max=x;
	sec=x;
	for (i=2;i<=n;i++){
		scanf("%d",&x);
		if (x>=max)
			max=x;
		if ((x<max)&&(x>=sec))
			sec=x;}
	printf("%d\n",max);
	printf("%d\n",sec);
}


int main(){
	int n,a,b,i,num;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
	scanf("%d",&num);
	   if(i==1){
	        a=num;
			b=num;

	  }else if(num>a){
		   b=a;
			a=num;
		}else if((a>num)&&(num>b)){
			b=num;
		}

	}
printf("%d\n%d\n",a,b);
	return 0;
}


int main ()

{
	int  sz[100];
    int  i,N,max1,max2;

	scanf("%d",&N);
	for( i=0;i<N;i++)
		scanf("%d",&sz[i]);
	max1=sz[0]>sz[1]?sz[0]:sz[1];
	max2=sz[0]>sz[1]?sz[1]:sz[0];
	for(i=2;i<N;i++)
	{
		if(sz[i]>max1)
		{
			max2=max1;
			max1=sz[i];
		}
		else if(sz[i]>max2)
			max2=sz[i];
	}
	printf("%d\n",max1);
	printf("%d\n",max2);
return 0;
}


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


int max(int a,int b){

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

void main (){

	int i,c;
	int n;
	int a=0;
	int b=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&c);
		b=max(min(a,c),min(a,b));
		a=max(a,c);
	}
	printf("%d\n",a);
	printf("%d\n",b);

}


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


int main()
{
	int first=-1;
	int second=-1;
	int i, n, a;
	scanf("%d", &n);
	for(i=1;i<=n; i++)
	{
		scanf("%d", &a);
		if(i==2){
			if(a>first){
				second=first;
				first=a;
			}else{
				second=a;
			}
		}
		if (a>first)
		{second=first;
			first=a;
		}
		else
		{continue;}
	}
    printf("%d\n%d",first,second);
	return 0;
}


int main(int argc, char* argv[])
{
	int num[1000],i,j,a,r,b,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&num[i]);
	a=num[0];
	for (j=1;j<n;j++)
	if (num[j]>=a)

	{
		a=num[j];
	}

b=-10000;
for(r=0;r<n;r++)
if(num[r]>=b&&num[r]!=a)
{
	b=num[r];
}
printf("%d\n%d",a,b);

	return 0;
}


int max(int a[100],int n,int m)
{
	int y,i;
	if(a[0]==m)  y=a[1];
    else y=a[0];
	for(i=0;i<n;i++)
	{
		if(a[i]==m)  continue;
		if(a[i]>y)   y=a[i];
	}
	return y;
}
int main()
{
	int a[100],n,i,m;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
    m= max(a,n,0);
    printf("%d\n",m);
	m= max(a,n,m);
    printf("%d\n",m);
	return 0;
}


void main()
{
	int n,i,max,secondmax;
	int num[100];

	scanf("%d",&n);

	scanf("%d",&num[0]);
	max=num[0];
	secondmax=num[0];

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

		if(num[i]>max)
			max=num[i];
		else if(num[i]>secondmax)
			secondmax=num[i];
	}

	printf("%d\n%d\n",max,secondmax);
}


int main()
{
int a,b,c,d,e,i;
i=1;
scanf("%d\n",&a);
while(i<=a)
{
	scanf("%d",&b);
if(i==1)
{
c=b;
d=b;
}
	if(b>c)
{
e=c;
c=b;
if(e>d)
d=e;
}
else if(b>d)
d=b;
i=i+1;
}
printf("%d\n%d\n",c,d);

return 0;
}


int main()
{
	int n;
	int number[120];
	scanf("%d",&n);
	int i,maxpos;

	for (i=0;i<n;i++)
		scanf("%d",&number[i]);
	int max=-100000, sndmax=-100000;
	for (i=0;i<n;i++) {
		if (number[i]>max) {
			max=number[i];
			maxpos=i;
		}
	}
	for (i=0;i<n;i++) {
		if (i==maxpos)
			continue;
		if (number[i]>sndmax)
			sndmax=number[i];
	}
	printf("%d\n%d\n",max,sndmax);
	return 0;
}


int main()
{
  int n,i,a;
  int max=0,min=0,temp=0;

  scanf("%d",&n);
  for(i=1; i<=n; i++)
  {
    scanf("%d",&a);
    if(i<=1)
    {

      max=max>a?max:a;

     }
    if(max<a&&i>1)
    {
     min=max;
     max=a;
    }
    if(max>a&&min<a&&i>1)
    min=a;

   }
   printf("%d\n%d",max,min);

   return 0;
}


int main()
{
	int a[100];
	int n,i;
	int p=0,q=0;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<n;i++)
		if(a[i]>p)
			q=p,p=a[i];
		else if(a[i]>q)
			q=a[i];
	cout<<p<<endl;
	cout<<q<<endl;
	return 0;
}


int yu7wuguan(int i);
int main(){
    int sz[100],i,n,k;
    int max,e;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
       scanf("%d",&sz[i]);
       }
    for(k=1;k<=2;k++)
    {
                     max=0;
        for(i=0;i<=n-k;i++)
        {
          if(sz[i]>sz[max])
          {
            max=i;
            }
            }
          if(max!=n-k)
          {
             e=sz[max];
             sz[max]=sz[n-k];
             sz[n-k]=e;
             }
           printf("%d\n",sz[n-k]);
             }

                return 0;
        }


int main(){
    int a,i,b,c,q,ist,sec;
	scanf("%d",&a);
	i=0;
	scanf("%d%d",&b,&c);
	if(b>c)ist=b,sec=c;
	else ist=c,sec=b;
	while(i<a-2){
		scanf("%d",&q);
		if(q>ist)
		{sec=ist;ist=q;}
		if(q>sec&&q<ist)
		{sec=q;}
		i++;
	}
	printf("%d\n%d",ist,sec);
	return 0;
}


int main()
{
	int a[100];
	int max,smax,i,n;
	max=smax=i=n=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	if(a[1]>a[2])
	{
		max=a[1];
		smax=a[2];
	}
	else
	{
		max=a[2];
		smax=a[1];
	}
	for(i=3;i<=n;i++)
	{
		if(a[i]>max)
		{
			smax=max;
			max=a[i];
		}
		else if(a[i]<=max&&a[i]>smax)
		{
			smax=a[i];
		}
	}
	printf("%d\n%d",max,smax);
	return 0;
}


void main()
{
  int n,a[100],i,max,secondmax;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  max=a[0];
  for(i=0;i<n;i++)
  {
    if(a[i]>max)
      max=a[i];
  }
  if(a[0]==max)
  {
    secondmax=a[1];
    for(i=1;i<n;i++)
    {
      if(a[i]>secondmax)secondmax=a[i];
    }
  }
  else
  {
    secondmax=a[0];
    for(i=0;i<n;i++)
    {
      if(a[i]<max&&a[i]>secondmax)secondmax=a[i];
    }
  }
  printf("%d\n",max);
  printf("%d\n",secondmax);
}


int main(int argc, char* argv[])
{
int n,e,i,m,t;
scanf("%d",&n);
int a,b,c;
scanf("%d %d",&a,&b);
if(a<b){
t=a;
b=a;
a=t;
}
for(i=0;i<n-2;i++){
scanf("%d",&c);
if(c>a){

e=b;
b=a;
a=c;
m=c;
}
else
if(a>c&&c>b)
{
m=b;
b=c;
c=m;
}
}
printf("%d\n%d\n",a,b);

	return 0;
}


int main()
{
 int arr[100]={0};
 int n,i,s,j;
n=0;
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
  scanf("%d",&arr[i]);
 }
 int max=-10000;
 for(s=0;s<n;s++)
 {
  max=(max>=arr[s])?max:arr[s];
 }
 int secondMax=0;
 for(j=0;j<n;j++)
 {
  secondMax=(secondMax>=arr[j]||arr[j]==max)?secondMax:arr[j];
 }
 printf("%d\n",max);
 printf("%d",secondMax);
 return 0;
}


int main()
{
	int n,i,max=0,secondmax=0;
	scanf("%d",&n);
	int num[100]={0};
	for(i=0;i<n;i++){
		scanf("%d",&num[i]);
	}
	for(i=0;i<n;i++){
		if(max<num[i])
			max=num[i];
	}
	for(i=0;i<n;i++){
		if(secondmax>=num[i])
			secondmax=secondmax;
		else if(num[i]==max)
	        secondmax=secondmax;
		else
			secondmax=num[i];
	}
	printf("%d\n%d\n",max,secondmax);
	return 0;
}


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


int main()
{
	int n,a,b,max1,max2,temp;
	scanf("%d%d%d",&n,&a,&b);
	max1=a;max2=b;
	for (int i=3;i<=n;i++)
	{
		scanf("%d",&temp);
		if (temp>=max1)
		{
			max2=max1;
			max1=temp;
		}
		else if(temp>=max2)
			max2=temp;
	}
	printf("%d\n%d\n",max1,max2);
	return 0;
}


void main()
{
	int n,b,c,i=1;
	scanf("%d",&n);
	b=0;
	c=0;
	do
	{
		int a;
		scanf("%d",&a);
		if(a>b)
		{
			c=b;
			b=a;
		}
		else
			if(a>c)
			{
				c=a;
				b=b;
			}
			else
			{
				c=c;
				b=b;
			}
		i=i+1;
	}
	while(i<=n);
	printf("%d\n%d",b,c);
}


int main()
{
 int arr[100];
 int n=0;
 scanf("%d",&n);
 for(int i=0;i<n;i++)
 {
  scanf("%d",&arr[i]);
 }
 int max=-10000;
 for(int s=0;s<n;s++)
 {
  max=(max>=arr[s])?max:arr[s];
 }
 int sm=-10000;
 for(int j=0;j<n;j++)
 {
      if(arr[j]!=max)
  {
if(arr[j]>sm)
sm=arr[j];
  }
 }
 printf("%d\n",max);
 printf("%d",sm);
 return 0;
}


int main(){
	int n,i,max,sum;
	int a[99];
	scanf("%d%d",&n,&a[0]);
	max=a[0];
	sum=a[0];
	for(i=1;i<=n-1;i++){
		scanf("%d",&a[i]);
		if(a[i]>max){
			sum=max;
			max=a[i];
		}
		if(max>a[i]&&(a[i]>sum)){
			sum=a[i];
		}
	}
	if(i<=99){
		printf("%d\n%d",max,sum);
	}
	return 0;
}


void main()
{
	int a,b=0,c=0,temp;
	scanf("%d",&a);
	for(;a>0;a--)
	{
		scanf("%d",&temp);
		if(temp>b)
		{
			c=b;b=temp;
		}
		else if(temp<=b && temp>c)
			c=temp;
	}
	printf("%d\n%d\n",b,c);

}


int cmp(const void * a, const void * b);
int main()
{
	int n;
	scanf("%d",&n);
	int *arr =  (int *) malloc (sizeof(int) * n);
	int i;
	for(i = 0; i < n; i++)
	{
		scanf("%d",&arr[i]);
	}
	qsort(arr,n,sizeof(arr[0]),cmp);
	printf("%d\n",arr[n-1]);
	printf("%d\n",arr[n-2]);
	scanf("%d",&n);
	return 0;
}
int cmp(const void * a, const void * b)
{
	return ((*(int*)a-*(int*)b>0)?1:-1);
}


int main()
{
	int r,i,max1=0,max2=0;
	int score[100];
	scanf("%d",&r);
    for(i=0;i<=r-1;i++)
	{
		scanf("%d",&score[i]);
	}
	for(i=0;i<=r-1;i++)
	{
		if(score[i] > max1 )
		{
max2 = max1;

			max1 = score[i];
					}
		else if( score[i] > max2 )
			max2 = score[i];

	 }
	printf("%d\n%d",max1,max2);
	 return 0;
}


void main()
{int n,i,k,max1,max2,num[30];
 scanf("%d",&n);
 for(i=0;i<n;i++)
    scanf("%d",&num[i]);
 max1=num[0];
 k=0;
 for(i=1;i<n;i++)
    if(num[i]>max1)
         {max1=num[i];k=i;}
 if(k=0)
 {max2=num[1];
  for(i=2;i<n;i++)
    if(num[i]>max2)
         max2=num[i];
  }
else {max2=num[0];
      for(i=2;i<n;i++)
          if(num[i]>max2&&num[i]!=max1)
          max2=num[i];
     }
printf("%d\n",max1);
printf("%d\n",max2);
}


void insert(int *ma,int tem)
{
if (tem>ma[0]){ ma[1]=ma[0];ma[0]=tem;}
else if (tem>ma[1]){ ma[1]=tem;}
}

int main()
{
int n,i;
int temp,max[2]={0,0};
scanf("%d",&n);
for (i=1;i<=n;i++){
     scanf("%d",&temp);
     if (temp>max[0]){ max[1]=max[0];max[0]=temp;}
     else if (temp>max[1]){ max[1]=temp;}
     }
 printf("%d\n%d",max[0],max[1]);
return 0;
}


int main(){
    int n,i,t;
    int max,cmax;
    int sz[100];
    scanf("%d",&n);
    for(i=0;i<n;i++){
                     scanf("%d",&sz[i]);
                     }
                     max=sz[0];
                     cmax=sz[1];
                     for(i=2;i<n;i++){
                                      if(sz[i]>max){
                                                   t=max;
                                                   max=sz[i];
                                                   cmax=t;
                                                   }else if(sz[i]>cmax&&sz[i]<max){
                                                         cmax=sz[i];
                                                         }
                                                         }
                                                         printf("%d\n%d\n",max,cmax);
                                                         return 0;
                                                         }


void main()
{
	int i,n;scanf("%d",&n);
	int *p,*hd;hd=p=(int *)malloc(n*sizeof(int));
	for(i=0;i<n;i++,p++)
	{
		scanf("%d",p);
	}
	int max=0;
	for(p=hd,i=0;i<n;i++,p++)
	{
		if(*p>max) max=*p;
	}
	for(p=hd,i=0;i<n;i++,p++)
	{
		if(*p==max) *p=0;
	}
	printf("%d\n",max);max=0;
	for(p=hd,i=0;i<n;i++,p++)
	{
		if(*p>max) max=*p;
	}
	printf("%d",max);
}


int main()
{
  int a;
  int num,result1,result2,cha;
  scanf("%d\n",&a);
  int i=1;
  while(i<=a){
     scanf("%d\n",&num);
    if(i==1){
       result1=num;
     } else if(i==2){
       result2=num;
       if(result2>result1){
          cha=result1;
          result1=result2;
          result2=cha;
        }
     } else if(i!=1&&i!=2){
       if(num>result1){
       result2=result1;
       result1=num;
       }else if(num>result2&&num<result1){
       result2=num;
       }
     }
  i++;
  }
  printf("%d\n%d\n",result1,result2);
  return 0;
}


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


int main(){
int n,e;
int x,y,z;
int i;
scanf("%d%d%d",&n,&x,&y);
if(x<y){
e=x;
x=y;
y=e;
}
for(i=1;i<=n-2;i++){
scanf("%d",&z);
if(x<z){
e=x;
x=z;
z=e;
if(z>y){
y=z;
}
}else if(x>z&&y<z){
x=x;
y=z;
}else if(z<y){
x=x;
y=y;
}
}
printf("%d\n%d",x,y);
return 0;
}


int main(int argc, char* argv[])
{
    int n,i=3,a;
	int max,sec;

	scanf("%d",&n);

	scanf("%d",&a);
	max=a;

	scanf("%d",&a);
	if (a>max)
	{
		sec=max;
		max=a;
	}
	else
	{
		sec=a;
	}

	for (i=3;i<=n;i++)
	{
		scanf("%d", &a);
	    if (a>max)
		{
			sec=max;
			max=a;
		}
		else if(a>sec)
		      {
		    	sec=a;
		      }
	}
	printf("%d\n%d\n",max,sec);

	return 0;
}


void main()
{
	int max,max2,n,i,a[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	for(i=0,max=max2=a[0];i<n;i++)
	{
		if(max<a[i]){
			max=a[i];
		}
	}
	for(i=0;i<n;i++)
	{
		if(max2<a[i]&&a[i]<max) max2=a[i];
	}
	printf("%d\n%d",max,max2);
	getchar();getchar();
}


int main()
{
	int n,i,max,min,e,k;
	i=0;
	k=1;
	scanf("%d\n",&n);
	int number[n];
	for(i=0;i<=n-1;i++){
		scanf("%d\n",&(number[i]));
	}
	for(k=1;k<=n;k++){
		for(i=0;i<=n-1-k;i++){
			if(number[i]>number[i+1]){
				e=number[i+1];
				number[i+1]=number[i];
				number[i]=e;
			}
		}
	}
	printf("%d\n%d\n",number[n-1],number[n-2]);
	return 0;
}


void main()
{
	int n,i,a,b,c;
	scanf("%d",&n);
	scanf("%d%d",&a,&b);
	for(i=3;i<=n;i=i++)
	{
		scanf("%d",&c);
		if(c>=a)
		{
			b=a;
			a=c;
		}
		else if(a>c&&c>b)
			b=c;
	}
	printf("%d\n%d",a,b);
}


int max(int a[],int n)
{
	int i,k=0;
	for(i=0;i<n;i++)
	{
		if(a[i]>a[k])
			k=i;
	}
	i=a[k];
	a[k]=0;
	return i;

}
int main()
{
	int n;
	scanf("%d",&n);
	int a[100],i;
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	printf("\n%d",max(a,n));
	printf("\n%d",max(a,n));
	return 0;
}


int main(){
int n;
scanf("%d",&n);
int max,sed,t,j,r,m,c;
scanf("%d",&max);
scanf("%d",&sed);
scanf("%d",&c);
j=3;
while(j<=n){
	if(max<c){
	t=max;
	max=c;
	c=t;
	}
	if(sed<c){
	r=sed;
	sed=c;
	}
	j++;
	scanf("%d",&c);

}
if(max<sed){
m=max;
max=sed;
sed=m;
}
printf("%d\n%d\n",max,sed);
return 0;
}


void main()
{
	int a,b,c,d,min,max;
	scanf("%d\n%d\n%d",&a,&c,&d);
	min=(d<c)?d:c;
	max=(d>=c)?d:c;
	if(a>2)
	for(;a>=3;a--)
	{
		scanf("%d",&b);
		if(b>max){min=max;max=b;}
		else if(b>min)min=b;

	}
	printf("%d\n%d",max,min);
}


int main()
{
	int k,max=0,max2=0,n,m;//max???????max2?????????n??????????m??????
	cin >> k;
	for(int i=0;i<k;i++)
	{
		cin >> n;
		if(n==1)
			max=n;
		else if(n==2)
		{
			max2=n;
			if(max2>max)
			{
				n=max2;
				max2=max;
				max=n;
			}
		}
		else
		{
			if(n>max)
			{
				max2=max;
				max=n;
			}

			else if (max>=n&&n>=max2)
				max2=n;
		}
	}
    cout << max << endl;
	cout << max2 << endl;
	return 0;
}


int main(int argc, char* argv[])
{
	int n,i,x,y,a;
	scanf("%d",&n);
	x=0;
	y=0;
	scanf("%d",&a);
	y=a;
	for (i=2;i<=n;i++)
	{
		int ai;
		scanf("%d\n",&ai);
		if (ai>=x)
		{
			x=ai;
		}
		else
		{
			if (ai>y)
			{
				y=ai;
			}
		}
	}
	printf("%d\n",x);
	printf("%d\n",y);
	return 0;
}


int main()
{
int max(int x,int y);
int min(int x,int y);
 int i=1,n,a,s,d,f,g;
 scanf("%d",&n);
 while(i<=n){
  scanf("%d\n",&a);
  if(i==1) { s=a;d=a;}
  else  { f=d;g=s;
        s=max(s,a);d=min(g,a);d=max(d,f);
    }
  i++;
 }

  printf("%d\n%d\n",s,d);
 return 0;
}
int max(int x,int y){
int z;
z=x>y? x:y;
return(z);
}
  int min(int x,int y){
 int z;
z=x<y? x:y;
return(z);
}


int main(int argc, char* argv[])
{
	int n,a,b,m;
   	scanf("%d",&n);
	for(a=0,b=0;n>0;n--)
	{
		scanf("%d",&m);
		if(m>a)
		{	b=a;
			a=m;

		}else if(m>b&&m<a)
		{
			b=m;

		}

	}
printf("%d\n%d",a,b);

	return 0;
}


int main()
{
	int a[100];
	int i=0,n,j,max,second;
	scanf("%d",&n);
	while(i<n)
	{
	scanf("%d",&a[i]);
	i=i+1;
	}
	i=0;
	max=a[0];
	while(i<n)
	{
	if(max<a[i])
	{
		max=a[i];
	    j=i;
	}
	    i=i+1;
	}
	i=0;
	if(j!=0) second=a[0];
	else second=a[1];
    while(i<n)
	{
		if(second<a[i]&&a[i]<max) second=a[i];
		i=i+1;
	}
	printf("%d\n%d\n",max,second);
}


int main()
{
 int Max,OnlyUnderMax,Min;
 int i,n,nums[100];
 cin>>n;
 cin>>nums[0];
 Max = Min = nums[0];
 for(i = 1;i<n;i++)
 {
  cin>>nums[i];
  if(nums[i]>Max)
   Max = nums[i];
  if(nums[i]<Min)
   Min = nums[i];
 }
 OnlyUnderMax = Min;
 for(i = 0;i<n;i++)
 {
  if(nums[i]>OnlyUnderMax && nums[i]<Max)
   OnlyUnderMax = nums[i];
 }
 cout<<Max<<endl<<OnlyUnderMax<<endl;
 return 0;
}


void main()
{
	int n,i,j,k,t,max1=0,min,max2;
	int a[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(j=0;j<n;j++)
	{
		if(max1<a[j])
			max1=a[j];
		else
			continue;
	}
	min=max1;
	for(k=0;k<n;k++)
	{
		t=max1-a[k];
		if(t==0)
			continue;
		else
		{
			if(min>t)
				min=t;
		    else
				continue;
		}
	}
	max2=max1-min;
	printf("%d\n%d\n",max1,max2);
}


int main ()
{
  int n,max1,max2,i,d,e,f;
  scanf("%d\n",&n);
  scanf("%d\n",&d);
  scanf("%d\n",&e);
  max2=e;
  max1=d;
  if (d>e)
{  max2=d;
   max1=e;
}

    for(i=2;i<n;i++)
{
  scanf("%d\n",&f);
  if (f>max2)
{  max1=max2;
   max2=f;
}
else if (f<=max1) ;
else
max1=f;
}
printf("%d\n%d",max2,max1);
return 0;
}


int main()
{
	int length = 0, a[110] = {0};
	cin >> length;
	for(int i = 0; i < length; i ++)
		cin >> a[i];
	int sec = 1;
	int point = 0;
	while(point + sec < length)
	{
		while(point + sec < length)
		{
			if(a[point] < a[point + sec])
			{
				int temp = a[point];
				a[point] = a[point + sec];
				a[point + sec] = temp;
			}
			point = point + sec * 2;
		}
		sec = sec * 2;
		point = 0;
	}
	cout << a[0] << endl;
	sec = sec / 4;
	if(a[sec] > a[sec * 2])
		cout << a[sec] << endl;
	else
		cout << a[sec * 2] << endl;
	return 0;
}


int main(int argc, char* argv[])
{
	int n,i,x[100];
	int max=0,secondmax=0;
	scanf("%d",&n);
    for(i=0;i<n;i++)
	{
		scanf("%d",&x[i]);
		if(x[i]>=max)
		{
		secondmax=max;
		max=x[i];
		}
		if(x[i]>secondmax&&max>x[i])
		{
			secondmax=x[i];
		}

	}
	printf("%d\n%d\n",max,secondmax);
	return 0;
}


int main()
{
int n;
int a=0;
int b=0;
cin>>n;
for (int i=1;i<=n;i++)
{
	int m;
	cin>>m;
	if(m>=a)
	{
		b=a;
		a=m;
	}
	else if(m>b)
		b=m;
}
printf("%d\n%d\n",a,b);
return 0;
}


int main()
{
	int n,i,a,b,max=0,sec;
	int number[1000];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&number[i]);
		if(number[i]>max){
			max=number[i];
		}
	}
		a=max;
		sec=max;
		for(i=0;i<n;i++){
			if((a-number[i])<sec&&(a-number[i]>0)){
					sec=a-number[i];
			}
		}

		b=a-sec;
		printf("%d\n",a);
		printf("%d\n",b);
		return 0;
	}


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


int main(){
	int i=0;
	int n;
	scanf("%d",&n);
	int a,b;
	int x,y,l;
	scanf("%d%d",&x,&y);
	if(x>y){
		a=x;
		b=y;
	}else{
		a=y;
		b=x;
	}
	while(i<=n-3){
		scanf("%d",&l);
		if(l>a){
			b=a;
			a=l;
		}else{
			if(l>b){
				b=l;
			}
		}
		i++;
	}
	printf("%d\n%d",a,b);
		return 0;
}


int main()
{
	int n, max1, max2,i;
	int num[100]={0};
	max1 = 0;
	max2 = 0;
	scanf("%d" , &n);
	scanf("%d%d", &num[0],&num[1]);
	if (num[0] >= num[1])
	{
		max1 = num[0];
		max2 = num[1];
	}
	else
	{
		max1 = num[1];
		max2 = num[0];
	}
    for (i = 2; i < n; i++)
	{
		scanf("%d" ,&num[i]);
		if (num[i] > max1)
		{
			max2 = max1;
			max1 = num[i];
		}
		else if (num[i] >max2)
		{
			max2 = num[i];
		}
		else
		{
			continue;
		}
	}
		printf("%d\n%d\n", max1,max2);
		return 0;
}


int main()
{
    int n,i,a,b,c;
    i=1;
    scanf("%d",&n);
    b=0;
    c=0;
    while(i<=n)
    {
               scanf("%d",&a);
               if(a>b)
               {
                      if(c<b)
                      {
                             c=b;
                      }
                      b=a;
               }
               else
               {
                   if(c<a)
                   {
                          c=a;
                   }
               }
               i++;

    }
    printf("%d\n",b);
    printf("%d\n",c);
    return 0;

}


int main(){
int n;
int max1,max2,num;
int exc;
max1=0;
max2=0;
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&num);
{if(num>max1){
exc=max1;
max1=num;
max2=exc;}else if(num<max1){if(num>max2){
max2=num;
max1=max1;}}
}}
printf("%d\n%d\n",max1,max2);

return 0;
}


int main(int argc, char *argv[])
{
    int n,a,max,min,i,e;
    scanf("%d",&n);
    for(i=0;i<n;i++){
                     scanf("%d",&a);
                     if(i==0) {
                              max=min=a;
                              }
                     if(a>max)  max=a;
                     else if(max>a && a>min)  min=a;
                     }

    printf("%d\n%d\n",max,min);

  return 0;
}


int main()
{
    int n,i,j,min,max1=0,max2=0;
    int a[100];
    cin>>n;
    for (i=0;i<n;i++) cin>>a[i];
    min=a[0];
    for (i=0;i<n;i++)
    {
        if (a[i]>max1) {max1=a[i];j=i;}
        if (a[i]<min) min=a[i];
    }
    a[j]=min;
    for (i=0;i<n;i++) if (a[i]>max2) max2=a[i];
    cout<<max1<<endl;
    cout<<max2<<endl;
return 0;
}


void main()
{
int a,b,c,n;
scanf("%d\n",&n);
scanf("%d\n",&a);
scanf("%d\n",&b);

while(n!=2)
{
scanf("%d\n",&c);
if (a>=b)
if (a>=c)
if (b>=c)
a=a;
else b=c;
else
{b=a;
a=c;}
else
if (a>=c)
{c=b;b=a;a=c;}
else
if(b>=c)
{a=b;b=c;}
else
a=c;

n=n-1;
}
printf("%d\n",a);
printf("%d\n",b);
}


int main()
{
	int n, i, k, sz[100],max,max1;
	scanf("%d\n",&n);
	for(i=0;i<=n-1;i++){
	scanf("%d\n", &(sz[i]));
	}
	max=max1=sz[0];
		for(i=0; i<n; i++){
			if(sz[i]>max){
            max=sz[i];
			}
		}
		for(i=0; i<n; i++){
			if(sz[i]<max&&sz[i]>max1){
            max1=sz[i];
			}
		}
	printf("%d\n%d", max, max1);
	return 0;
}


int main()
{
	int n,a[100],i,diyi,dier;
	scanf("%d",&n);
	for(i=0;i<=n-1;i++)
	scanf("%d",&a[i]);
	diyi=a[0];
	dier=a[1];
    for(i=1;i<=n-1;i++)
	{
		if(a[i]>=diyi)
		{
			dier=diyi;
		    diyi=a[i];
		}
		if(a[i]<diyi&&a[i]>=dier)
		dier=a[i];
	}
	printf("%d\n%d",diyi,dier);
	return 0;
}


void main()
{
	long int k,i=0,a,b,c=0,d;
	scanf("%d\n",&k);
	k=k-1;
	for (;i<=k;i++)
	{
		scanf("%d\n",&a);
		if(a<b)
		{
			if(a>c)
				c=a,b=b;
			else
				c=c,b=b;
		}
		else
			if (d>c)
				c=b,b=a;
			else
				c=c,b=a;
	}
	printf("%ld\n%ld\n",b,c);
}


int main(){
   int max1,max2,num,i=1;
   int n,c,d;
   int exc;
    scanf("%d",&n);
   while (i<=n){
               scanf("%d",&num);
               if(i==1){max1=num;}
               else if(i==2){max2=num;
               if(max1<max2){c=max1;max1=max2;max2=c;}
                }
               else {if(max1<num){d=max1;max1=num;num=d;}
               max2=max2>num?max2:num;}
               i++;
              }
printf("%d\n%d\n",max1,max2);
return 0;
}


int main()
{
	int n;
	scanf("%d", &n);
	int max;
	scanf("%d", &max);
	int lmax;
	scanf("%d", &lmax);
	if(max<lmax)
	{
		max=lmax;
		lmax=max;
	}
    int a;
	int i;
	for(i=0;i<(n-2);i++)
	{
		scanf("%d", &a);
	    if(a>max)
		{
			lmax=max;
		     max=a;
		}
	    else if(a>lmax)
		{
		     lmax=a;
		}
	}
	printf("%d\n", max);
	printf("%d", lmax);
	return 0;
}


void main()
{
	int k,i,j,a,b,c,m,n,p;
	scanf("%d\n",&k);
	m=0;
	p=0;
    for(i=1;i<=k;i++)
	{
		scanf("%d\n",&a);
		  if(a>=m)
			{ n=a;
		      if(p>m)
			  j=p;
			  else
			  j=m;
			}
          else
			{n=m;
			 if(p>a)
			  j=p;
			  else
			  j=a;
			}
			m=n;
			p=j;

	}
	printf("%d\n%d\n",n,j);

}


int main(){
    int max1,max2,num,i=1;
    while(i<=10){
    scanf("%d",&num);
    if(i==1){
      max1=num;
    }else if(i==2){
    if(num>max1){
       max2=max1;
       max1=num;
     }else{
      max2=num;
     }
     }else{
     if(num>max1){
     max2=max1;
     max1=num;
}else if(num>max2&&num<max1){
max2=num;
}
}
i++;
}
printf("%d\n%d\n",max1,max2);
return 0;
}


void main()
{
	int m=1,n,a,b,c;
	scanf("%d",&n);
	scanf("%d%d",&b,&c);
	if(c>b)
	{
		c=c+b;b=c-b;c=c-b;
	}
	while (m<=n)
	{
		scanf("%d",&a);
		if (a>b)
		{
			a=a+b;b=a-b;a=a-b;
		}
		else if (a>c)
		{
			a=a+c;c=a-c;a=a-c;
		}
		m++;
	}
	printf("%d\n%d",b,c);
}


int mycompare(const void* e1, const void* e2)
{
	return *((int*)e2) - *((int*)e1);
}

int main()
{
	int n, s[101];
	scanf("%d", &n);
	for(int i = 0; i < n; i ++)
	{
		scanf("%d", &s[i]);
	}
	qsort(s, n, sizeof(int), mycompare);
	cout << s[0] << endl << s[1] << endl;

	return 0;
}


int main()
{
	int a, b=-1,c=-2;
	scanf("%d",&a);
	int d;
	for(int i=0;i<a;i++){
		scanf("%d",&d);
		if(d>b){
			c = b;
			b = d;
		}
		else if(d<b && d>c){
			c = d;
		}
	}
    printf("%d\n%d",b,c);
	return 0;
}


void main()
{
	int a[100],i,n,max1,max2;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	max1=a[0];

	for(i=1;i<n;i++)
	{
		if(a[i]>max1)
		{
			max1=a[i];
		continue;
		}
		else
				continue;
	}
	max2=a[0];
		for(i=1;i<n;i++)
		{
			if(a[i]<max1&&a[i]>max2)
			{
				max2=a[i];
			continue;
			}
			else
				continue;
		}
		printf("%d\n%d\n",max1,max2);
}


int main()
{
	int a;
	scanf("%d",&a);
	int n[100];
	int i;
	for(i=0;i<a;i++)
	{
		scanf("%d",&n[i]);
	}
	int max=n[0];
	int j;
	for(j=1;j<a;j++)
	{
		if (n[j]>max)
		{
			max=n[j];
		}
	}
	printf("%d",max);
	int next=n[0];
	int q;
	for(q=1;q<a;q++)
	{
		if(n[q]>=next&&n[q]<max)
		{
			next=n[q];
		}
	}
	printf("\n%d\n",next);
	return 0;
}


int main(int argc, char* argv[])
{
	int n,i,x;
	scanf("%d", &n);
	int first, second;
	for (i=1;i<=n;i++)
	{
		if (i<n)
		{
			scanf("%d\n", &x);
		}
		else
		{
			scanf("%d", &x);
		}

		if (i==1)
		{
			first=x;
		}
		else if (i==2)
		{
			if (x>first)
			{
				second=first;
				first=x;
			}
			else
			{
				second=x;
			}
		}
		else
		{
			if (x>first)
			{
				second=first;
				first=x;
			}
			else if (x>second)
			{
				second=x;
			}
		}
	}
	printf("%d\n", first);
	printf("%d\n", second);
	return 0;
}


int main()
{
int num,n;
int max,sec;

  scanf("%d",&n);
  for(int i=0 ;i<n;i++)
  {
	 scanf("%d",&num);

	 if(i==0)
	 {
		 max=num;
	 }

	 else if(i!=0)
	 {

		 if(num>max)
		 {
			 sec=max;
			 max=num;
		 }
		 else if(num>sec && num<max)
		 {
			 sec=num;
		 }
	 }

  }
	printf("%d\n%d\n",max,sec);
	return 0;
}


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


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


int main(){
	int n, m;
	int i=0, max1=0, max2=0, tmp=0;
    scanf("%d", &n);
   	for(i=0; i<n; i++){
		scanf("%d", &m);
		if(m>max1){
			tmp = max1;
			max1 = m;
			max2 = tmp;
		}
		else {
			if(m<max1 && m>max2){
				max1 = max1;
			    max2 = m;
			}
			else{
				max1 = max1;
				max2 = max2;
			}
	}
	}
	printf("%d\n", max1);
         printf("%d\n", max2);
	return 0;
}


int max(int sz[],int n)
{
	int i,max;
	for(i=0;i<n;i++){
		if(sz[i]>max){
			max=sz[i];
		}
	}
	return max;
}
int main()
{
	int n,m,i;
	scanf("%d",&n);
	int sz[100];
	for(i=0;i<n;i++){
		scanf("%d",&sz[i]);
	}
	int max=sz[0],sec=sz[0];
	for(i=0;i<n;i++){
		if(sz[i]>max){
			max=sz[i];
			m=i;
		}
	}
	sz[m]=-1;
	for(i=0;i<n;i++){
		if(sz[i]>sec){
			sec=sz[i];
		}
	}
	printf("%d\n%d\n",max,sec);
	return 0;
}


int main()
{
	int max=0,submax=0,i,n,x;
	scanf("%d/n",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&x);
	if (i==0)
	{
		max=x;
		submax=x;

	}
	else if(i==1)
	{
		if(x>max)
		{
			submax=max;
			max=x;
		}
		else
		{
			submax=x;
		}
	}
	else
		{
		if(x>max)
		{
			submax=max;
			max=x;
		}
	else if(x>submax)
		{
			submax=x;
		}

	}
	}
    printf("%d\n",max);
	printf("%d\n",submax);
	return 0;
}


int main()
{
	int a, b, c;
	int j, i;
    scanf("%d", &j);
	for (i=0;i<j;i++)
	{
		scanf("%d", &a);
		if(i==0)
		{
			c=a;
			b=a;
		}
		else if(i>=2)
		{
			if(b>a)
			{
				if(c<a)
					c=a;
				else if(c>a&&c>b)
				{
					a=b;
					b=c;
					c=a;
				}
			}
			else if(b<a&&c<b)
			{
			c=b;
			b=a;
			}
			else if(b<a&&c>=b)
			{
				b=a;
			}
		}
		else if(b<a)
		b=a;
	}
	printf("%d\n", b);
	printf("%d", c);
	return 0;
}


int main()
{
    int a[100],i,max=0,t;
	scanf("%d",&i);
	while(i>0)
	{
		scanf("%d",&a[i]);
		if(a[i]>max)
		{
			t=max;
			max=a[i];
		}
		else if(t<a[i])
		{
			t=a[i];
		}
		i--;
	}
	printf("%d\n",max);
	printf("%d",t);
	return 0;
}


void main()
{
	int n,i,a,c,d;
	scanf("%d\n",&n);
	i=1;
	scanf("%d\n",&a);
	c=a;
	while(i<n)
	{	scanf("%d\n",&a);
	if(c<a)
	{
		d=c;
	c=a;
	}
	else
		if(d<a)
		d=a;
	i++;
	}
	printf("%d\n",c);
	printf("%d\n",d);

}


int main()
{
	int n=0;
	scanf("%d",&n);
	int i=1;
	int x=0,y=0;

	for(i=1;i<=n;i++){
		int t;
		scanf("%d",&t);
		if(i==1){
			x=t;
		}
		else if(i==2){
			y=t;
		}

		if(x<y){
			int z=x;
			x=y;
			y=z;
		}

		if(t>x){
			y=x;
			x=t;
		}
		else if (t<x&&t>y){
		y=t;

		}

	}
	printf("%d\n%d\n",x,y);

	return 0;
}


int main()
{
	int n,m,i;
	scanf("%d",&n);
	int sz[100];
	for(i=0;i<n;i++){
		scanf("%d",&sz[i]);
	}
	int max=sz[0],sec=sz[0];
	for(i=0;i<n;i++){
		if(sz[i]>max){
			max=sz[i];
			m=i;
		}
	}
	sz[m]=-1;
	for(i=0;i<n;i++){
		if(sz[i]>sec){
			sec=sz[i];
		}
	}
	printf("%d\n%d\n",max,sec);
	return 0;
}


void main()
{
	char n,i;
	int a[N],*p,max,*pmax;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	max=a[0];
	for(p=a;p<a+n;p++)
		if(max<*p)
			max=*p;
	printf("%d\n",max);
	if(max!=a[0])
		pmax=a;
	else
		pmax=a+1;
	for(p=a;p<a+n;p++)
		if(*pmax<*p&&*p<max)
			pmax=p;
	printf("%d",*pmax);
}


int main()
{
	int a[100];
	int n;
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	int max,sec;
	max=a[0];
	sec=a[0];
	for(i=1;i<n;i++)
	{if(a[i]>max)
			max=a[i];
	 if(a[i]<max&&a[i]>sec)
		    sec=a[i];
	}
	printf("%d\n%d\n",max,sec);
}


void operate(int a[],int n)
{	int i,pointer=0,max=a[0];
	for(i=0;i<n;i++)
	 if(a[i]>max) {pointer=i;max=a[i];}
	a[pointer]=0;
	printf("%d\n",max);
}
void main()
{	int i,n,a[101];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	operate(a,n);
	operate(a,n);
}


void main()
{
	int k,a,b,c,max,xmax;
	scanf("%d",&k);
	scanf("%d",&a);
	scanf("%d",&b);
	while(k>=3)
	{
		scanf("%d",&c);
		if(a>=c)
		{
			if(c>=b){max=a;xmax=c;}
			else if(a>=b){max=a;xmax=b;}
			else {max=b;xmax=a;}
		}
		else
		{
			if(a>=b){max=c;xmax=a;}
			else if(c>=b){max=c;xmax=b;}
				 else {max=b;xmax=c;}
		}
		a=max;b=xmax;
		k--;
	}
	printf("%d\n%d\n",max,xmax);
}


int main(){
    int c,d,n;
    int b=0;
    int a=0;
    int i=1;
    scanf("%d\n",&n);
    for(i=1;i<=n;i++){
        scanf("%d\n",&c);
        if(b>a){
              d=a;
              a=b;
              b=d;
        }
        if(c>=a&&a>=b){
              b=a;
              a=c;
        }
        if(a>c&&c>b){
              b=c;
        }
    }
    printf("%d\n%d",a,b);
    return 0;
}


int main(int argc, char* argv[])
{
	int n;
	scanf("%d", &n);
	int i, t, x, max, secondmax;
	scanf("%d", &t);
	max=secondmax=t;
	for (i=1;i<n;i++)
	{
		scanf("%d", &x);

		if (x>max)
		{
			secondmax=max;
			max=x;
			}
		else if(x>secondmax)
		{
			secondmax=x;

		}
	}printf("%d\n%d\n", max, secondmax);
	return 0;
}


void main()
{
int k,i,a,b,c,d,max1,max2;
scanf("%d %d %d",&k,&a,&b);
if(a>b)
max1=a,max2=b;
else
max1=b,max2=a;
for(i=1;i<=k-2;i++)
{
scanf("%d",&c);
if(c>max1)
d=max1,max1=c,max2=d;
else
if(c>max2)
max2=c;
}
printf("%d\n",max1);
printf("%d\n",max2);
}


int main(int argc, char* argv[])
{
	int i,n,t,m1=0,m2=0;
	scanf("%d",&n);
	for (i=0;i<n;i++){
		scanf("%d",&t);
		if (t > m1){
			m2=m1;
		    m1=t;
		}
	}
	printf("%d\n%d\n",m1,m2);
	return 0;
}


 int main()
 {
 int a=1,b=0;
 int n ,i;
 int x ,q;

 scanf("%d",&n);
 for(i=0;i<n;i++)
    {
       scanf("%d",&x);

       q=(x>a)+(x>b)  ;

       switch(q)
       {
       case 2:

          b=a,a=x;
          break;
       case 1:
          b=x;
          break;
       case 0:
          break;

       }
    }
  printf("%d\n%d",a,b);

  return 0;

  }


int main()
{
	int a;
	scanf("%d",&a);
	int i;
	int max1;
	int max2;
	int b;
	int c;
	scanf("%d%d",&b,&c);
	max1=b;
	max2=c;
	int k;
	int t;
	if (max1<max2)
	{
		t=max1;
		k=max2;
		max1=k;
		max2=t;
	}
	for (i=2;i<a;i++)
	{
        int m;
		scanf("%d",&m);
		if(m>max1)
		{
			max2=max1;
			max1=m;
		}
		else if(m>max2)
		{
			max2=m;
		}

	}
	printf("%d\n%d",max1,max2);

}


void swep(int *m,int*n)
{
	int t;
	t=*m;
	*m=*n;
	*n=t;
}

main()
{int n;
int i;
int *a;
int b,c;

cin>>n;
a=(int*)malloc(sizeof(int)*n);

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

b=a[0];
c=a[1];
if(c>b)
swep(&b,&c);

for(i=2;i<n;i++)
{
	if(a[i]>b)
	{
		c=b;
		b=a[i];
	}
	else if (a[i]>c)
		c=a[i];
}
cout<<b<<endl<<c;
return 0;
}


int main()
{
   int n,i,max,next,temp;
   scanf("%d",&n);
   int a[100];
   for(i=0;i<n;i++)
   { scanf("%d\n",&a[i]);
    }
   if(a[0]>a[1])
    {max=a[0];
     next=a[1];
     }
   else if(a[1]>a[0])
   {max=a[1];
    next=a[0];
    }
   for(i=2;i<n;i++)
   {if(a[i]>max)
      {temp=max;
      next=temp;
	  max=a[i];
      }
     else if(a[i]<max&&a[i]>next)
      next=a[i];
    }
    printf("%d\n%d",max,next);
    return 0;
}


int main()
{
  int n,i,max=0,emax=0;
  int a[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
   scanf("%d",&a[i]);
 if(a[i]>max){
   max=a[i];
  }
  }
  for(i=0;i<n;i++){
    if(a[i]!=max){
         if(a[i]>emax){
             emax=a[i];
           }
       }
    }
 printf("%d\n%d\n",max,emax);
 return 0;
}


int main()
{
	int max,max2,n,now;
	scanf("%d",&n);
	max=max2=-10000;
	while (n-->0)
	{
		scanf("%d",&now);
		if (now>max)
		{
			max2=max;
			max=now;
		}
		else
			if (now==max) max2=max;
				else
					if (now>max2) max2=now;
	}
	printf("%d\n%d",max,max2);
	return 0;
}


int main()
{
	 int num,i,s[100];
	 int j,k,l,p;
	 int max(int a,int b,int c), min(int a,int b,int c);

	 scanf("%d\n",&num);

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

		  scanf("%d\n",&s[i]);
	 }

	 k=s[0];
	 j=s[1];

	 for(i=2;i<=num-1;i++)
	 {

	      l=min(k,j,s[i]);
		  p=k;
		  k=max(k,j,s[i]);
		  j=j+p+s[i]-k-l;
	 }

	 printf("%d\n%d",k,j);

     return 0;
}

max( int a, int b, int c)
{
	  int m;
	  m=a>b?a:b;
	  m=m>c?m:c;
	  return m;
}

min( int a,int b,int c)
{
	  int s;
	  s=a>b?b:a;
	  s=s>c?c:s;
	  return s;
}


int main(int argc, char* argv[])
{
	int a;
	int b;
	int i=1;
	int m=0,n=0;
	scanf("%d\n",&a);
	while(i<=a)
	{
		scanf("%d\n",&b);
			if(b>=m)
			{
				n=m;
				m=b;
			}
			if(b<m&&b>n)
			{
				n=b;
			}
			i++;
	}
		printf("%d\n",m);
		printf("%d\n",n);

	return 0;
}


int main()
{
	int n;
	int s,t,r;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int NUMBER;
		scanf("%d",&NUMBER);
		switch(i)
		{
		case 0:
			s=NUMBER;
			break;
		case 1:
			t=NUMBER;
			if(s<t)
			{
				r=s;
				s=t;
				t=r;
			}
			break;
		default:
			if(NUMBER>s)
			{
				r=s;
				s=t;
				t=r;
				r=NUMBER;
				NUMBER=s;
				s=r;
			}
			else if(NUMBER>t)
			{
				r=NUMBER;
				NUMBER=t;
				t=r;
			}
			break;
		}
	}
	printf("%d\n%d\n",s,t);
	return 0;
}


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


int main()
{
   int n,t,e,max,smax;
   scanf("%d",&n);
   for(int i=0;i<n;i++){
   scanf("%d",&t);
   if(i==0){
   max=t;}
   if(i==1){
	   if(t>=max){

   e=max;
   max=t;
   smax=e;
	   }
	   else{
		   smax=t;
	   }
   }
   if(i>>1){
	   if(t>=max){
   e=max;
   max=t;
   smax=e;
   }
   if(t>=smax&&t<max){
	   smax=t;
   }
 }
   }
   printf("%d\n%d",max,smax);
   return 0;
}


int main()
{
    int n,a[100],i=0,max=0,max2=0;
	scanf("%d",&n);
	while(i<n)
	{
		scanf("%d",&a[i]);
		if(a[i]>max&&a[i]>max2)
		{
			max2=max;
			max=a[i];
        }
		else if(a[i]<max&&a[i]>max2)
			max2=a[i];
		i++;
	}
    printf("%d\n%d\n",max,max2);
	return 0;
}


int main()
{
	int n,i=0,j=0,temp;
	cin>>n;
	cin>>i;
	cin>>j;
	n=n-2;
	while (n--) {
          cin>>temp;
		  if (temp>i) {
			  j=i;
			  i=temp;
          }
		  if (temp<i&&temp>j) {
			  j=temp;
		  }

	}
	cout<<i<<endl;
	cout<<j<<endl;

}


int main()
{
    int n,i,a,max,imax;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        switch(i)
        {
            case 1: scanf("%d",&imax); break;
            case 2: scanf("%d",&a);
                    if(a>imax)
                    {
                        max=imax;
                        a=imax;
                    }
                    else max=a;
                    break;
            default:scanf("%d",&a);
                    if(a>=imax)
                    {
                        max=imax;
                        imax=a;
                    }
                    else if(a<imax&&a>=max)
                    {
                        max=a;
                    }
        }
    }
    printf("%d\n%d\n",imax,max);
    return 0;
}


int main()
{
 int   n,i=0,b,max1=0,max2=0;
scanf("%d",&n);
while(i<=n)
{
scanf("%d",&b);
if(b>max1)
{
 max2=max1;
 max1=b;
 }
else if(max1>b&&b>max2)
{
max1;
max2=b;
}
else if(max2>b)
{
max1;
max2;
}
i++;
}
printf("%d\n%d\n",max1,max2);
return 0;
}


int main(int argc, char* argv[]){
	int n, i=1, max=0, max2=0, a;
	scanf("%d", &n);
	for (i=1; i<=n; i++){
		scanf("%d", &a);
		if (a>=max){
			max2=max;
			max=a;
			continue;
		}
		else if((a<max)&&(a>=max2)){
			max2=a;
			continue;
		}
		else continue;
	}
	printf("%d\n%d\n",max,max2);
	return 0;
}


int main()
{
	int n,i,m,p,j;
	scanf("%d %d",&n,&m);
	i=2;
	p=0;
	while(i<=n)
	{
		i=i+1;
		scanf("%d",&j);
		if(m<=j)
		{
			p=m;
			m=j;
		}
		else if(p<j)
		{
			m=m;
			p=j;

		}
	}
	printf("%d\n%d",m,p);
	return 0;
}


int main()
{
	int r1,r2,i,n,num;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&num);
		if(i==1){
			r1=num;
		    r2=r1;
		}
		else{
			if(r1<num){
				r2=r1;
				r1=num;
			}
			else if(num<r1){
				if(r1==r2)
					r2=num;
				else if(r2<num&&num<r1)
					r2=num;
			}
		}
	}
	printf("%d\n%d\n",r1,r2);
	return 0;
}


void main()
{
int n, i;
scanf("%d", &n);
int a[n];
for(i=0;i<n;i++)
   {
    scanf("%d", &a[i]);
   }
int fir=a[1], sec=0;
for (i=0; i<n; i++)
   {
    if (fir<a[i])
      fir=a[i];
    }
for (i=0; i<n; i++)
   {
    if (sec<a[i]&&a[i]!=fir)
    sec=a[i];
   }
printf ("%d\n%d", fir, sec);
}


int  main (){
	int a,b,c,d,max,second,n;
	scanf("%d%d",&n,&b);
	a=1;
	max=b;
	second=0;
	while(a<n){
         scanf("%d",&c);
		 if(c>=max){
			d=max;
			max=c;
			second=d;
		 }
		 if((max>c)&&(c>=second)){

			 second=c;
		 }

		 a+=1;
	}
	printf("%d\n%d\n",max,second);
	return 0;
}


int main(int argc, char* argv[])
{
	int k,i=2,a,b,n,m;
	scanf("%d\n%d",&k,&m);
         a=m;
	b=m;
	while(i<=k)
	{
		scanf("%d",&n);
		if(n>a)
		{
			a=n;
		}
                  if(n<a&&n>b)
                  {
                           b=n;
                  }
		i++;
	}

	printf("%d\n%d\n",a,b);

	return 0;
}


int main()
{
int n,i,r,fm,sm;
int shu[100];
scanf("%d\n",&n);
for(i=0;i<n;i++)
scanf("%d\n",&shu[i]);
for(i=n-1;i>0;i--)
{
for(r=0;r<i;r++)
{
if(shu[r]>shu[r+1])
{
int tmp;
tmp=shu[r+1];
shu[r+1]=shu[r];
shu[r]=tmp;
}
}
}
fm=shu[n-1];
sm=shu[n-2];
printf("%d\n",fm);
printf("%d\n",sm);
return 0;
}


int main()
{
    int n,max,lmax,b,i;
    int x[100];
    scanf("%d",&n);
    scanf("%d",&x[0]);
    max=x[0];
    lmax=x[0];
    for(i=2;i<=n;i++)
    {
    scanf("%d",&x[i-1]);
    b=x[i-1];
    if (b>max)
       {
         if(max>lmax)
         {
           lmax=max;
         }
         max=b;
       }
    else if (b>lmax)
        {
         lmax=b;
         }
    }
   printf("%d\n%d\n",max,lmax);
      scanf("%d",&n);
      return 0;
}


int main(int argc, char* argv[])
{
	int e,len;
	scanf("%d",&len);
	int num[100];
	for(int i=0;i<len;i++)
		scanf("%d",&(num[i]));
	for(int k=1;k<len;k++){
		for(int i=0;i<len-k;i++){
			if(num[i]<num[i+1]){
				e=num[i+1];
				num[i+1]=num[i];
				num[i]=e;
			}
		}
	}
	printf("%d\n%d\n",num[0],num[1]);
	return 0;
}


int max(int x,int y)
{
	if(x>=y)
		return x;
	else
		return y;
}
int main()
{
	int n,a[1000],maxtemp,maxtemp2;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	maxtemp=maxtemp2=a[0];
	for(int i=0;i<n;i++)
	    maxtemp=max(maxtemp,a[i]);
	for(int i=0;i<n;i++)
		if(a[i]==maxtemp)
			a[i]=-1000000000;
	for(int i=0;i<n;i++)
		maxtemp2=max(maxtemp2,a[i]);
	cout<<maxtemp<<"\n"<<maxtemp2<<endl;

	return 0;
}


int main()

{

    int n,i,m,a,p,q,b;

    scanf("%d",&n);

    scanf("%d",&p);

    scanf("%d",&q);

    if(p>q){

       a=p;

b=q;

    }

    else if(p<=q){

       a=q;

       b=p;

    }

    i=3;

    while(i<=n){

    scanf("%d",&m);

    if(m>a){

       b=a;

       a=m;

    }

else if(m>b){

       b=m;

    }

    i++;

    }

    printf("%d\n%d\n",a,b);

    return 0;

}


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


int first(char p)
{
	int z=0;
	if(p=='_' || (p>='a' && p<='z') || (p>='A' && p<='Z'))
		z=1;
	return z;
}

int behind(char p)
{
	int z=0;
	if(p=='_' || (p>='a' && p<='z') || (p>='A' && p<='Z') || p=='0' || (p>='1' && p<='9'))
		z=1;
	else
		z=0;
	return z;
}

int main()
{
	char *p;
	int *tf;
	int n,i,j,len;
	scanf("%d",&n);
	p=(char*)malloc(sizeof(int)*25);
	tf=(int*)malloc(sizeof(int)*n);
	for(i=0;i<n;i++)
	{
		scanf("%s", p);
		len=strlen(p);
		tf[i]=1;
		if(first(p[0])==0)
		{
			tf[i]=0;
			continue;
		}
		for(j=1;j<len;j++)
		{
			if(behind(p[j])==0)
			{
				tf[i]=0;
				break;
			}
		}
	}
	for(i=0;i<n;i++)
	{
		if(tf[i]==0)
			printf("no\n");
		if(tf[i]==1)
			printf("yes\n");
	}
	free(p);
	return 0;
}


void fun(char data[])
{
     int len = strlen(data);
     int i;
     int ya;

     ya = ( *data == '_' || (*data >= 'A' && *data <= 'z') );

     for(i = 1; i <= len - 1; i++)
           if(!alphabet && !number)
                     ya = 0;

     if(ya == 0) printf("no\n"); else printf("yes\n");

}

int main()
{
    int n;
    scanf("%d\n", &n);
    int i;
    char data[81];

    for(i = 1; i <= n; i++)
    {
          gets(data);
          fun(data);
    }

    return 0;
}


int main()
{
	int n,i,len,j,e;
	char name[LEN];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		e=1;
		scanf("%s",name);
		len=strlen(name);
		if(name[0]!='_'&&isalpha(name[0])==0)
		{
			printf("no\n");
		}
		else
		{
			for(j=1;j<len;j++)
			{
				if(name[j]=='_'||(name[j]<58&&name[j]>47)||isalpha(name[j]))
				{
					e=1;
				}
				else
				{
					e=0;
					break;
				}
			}
			if(e==1)
			{
				printf("yes\n");
			}
			else
			{
				printf("no\n");
			}
		}
	}
	return 0;
}


int main() {
    int n;
    char str[1024];
    scanf("%d", &n);
    int flag;
    while (n--) {
        flag = 1;
        scanf("%s", str);
        int len = strlen(str);
        for (int i = 0; i < len; ++i) {
            if (isalpha(str[i]) || str[i] == '_')
                continue;
            else if (i != 0 && isdigit(str[i]))
                continue;
            else {
                flag = 0;
                break;
            }
        }
        if (flag)
            printf("yes\n");
        else
            printf("no\n");
    }
}


int main(int argc, char* argv[])
{
	int i, j, n, t, flag;
	char syx[21];
	scanf("%d", &n);
	for (i=0; i<n; i++)
	{
		flag = 1;
		scanf("%s", syx);
		t = strlen(syx);
		for (j=0; j<t; j++)
		{
			if(syx[j]==95)
				continue;
			else if(j==0 && syx[j] < 65 || syx[j] > 90 && syx[j] < 94 || syx[j]>122)
			{
				flag = 0;
				break;
			}
			else if(syx[j] < 48 || syx[j]>57 && syx[j] < 65 || syx[j] > 90 && syx[j] <97 || syx[j] > 122)
			{
				flag = 0;
				break;
			}
		}
		if (flag == 0)
			printf("no\n");
		else
			printf("yes\n");
	}

	return 0;
}


//?? C ???

//??????
int isKeyWord(char* str)
{
	int i;
	char *keyword[]=
					{
						"auto", "break", "case", "char", "const", "continue", "default",
						"do", "double", "else", "enum", "extern", "float", "for", "goto",
						"if", "int", "long", "register", "return", "short", "signed",
						"sizeof", "static", "struct", "switch", "typedef", "union", "unsigned",
						"void", "volatile", "while"
					};

	for (i = 0; i < 32; i++)
	{
		if (strcmp(str, keyword[i]) == 0)
			return 1;

	}
	return 0;
}

//??????C?????
int islegalIdentifier(char* str)
{
	char* p = str;
	if (isKeyWord(str))
		return 0;

	if (!((*p >= 'a' && *p <='z') || (*p >= 'A' && *p <='Z') || (*p == '_')))
		return 0;

	while (*p != '\0')
	{
		if (!((*p >= 'a' && *p <='z') || (*p >= 'A' && *p <='Z') || (*p == '_') || (*p >= '0' && *p <='9')))
			return 0;
		p++;
	}
	return 1;
}

int main()
{
	char buffer[21];
	int n, i;
	scanf("%d", &n);
	gets(buffer);

	for (i = 0; i < n; i++)
	{
		gets(buffer);
		if (islegalIdentifier(buffer))
			puts("yes");
		else
			puts("no");
	}

	return 0;
}


int main()
{
	int i,n,j,panduan=1;
	char s[100][100];
    scanf("%d",&n);
	for(i=0;i<n;i++)
	{
    	scanf("%s",s[i]);
	}
	for(i=0;i<n;i++)
	{
	panduan=1;
int m=strlen(s[i]);
		for(j=0;j<m;j++)
		{
			if(j==0)
			{
				if((s[i][j]>='a')&&(s[i][j]<='z'))
				{
				   continue;
				}
			    else if((s[i][j]>='A')&&(s[i][j]<='Z'))
				{
				   continue;
				}
                else if(s[i][j]=='_')
				{
				   continue;
				}
				else
				{
					panduan=0;
					break;
				}
			}
			else
			{
                 if((s[i][j]>='0')&&(s[i][j]<='9'))
				 {
				    continue;
				 }
			     else if((s[i][j]>='a')&&(s[i][j]<='z'))
				 {
			       	continue;
				 }
			     else if((s[i][j]>='A')&&(s[i][j]<='Z'))
				 {
				    continue;
				 }
			     else if(s[i][j]=='_')
				 {
				    continue;
				 }
				 else
				 {
					 panduan=0;
					 break;
				 }
			}
		}

		if(panduan==1)
		{
			   printf("yes\n");
		}
		else if(panduan==0)
		{
			   printf("no\n");
		}

	}

	return 0;
}


int main(int argc, char* argv[])
{
	int i,j,n,temp=0;
	char s[20];
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%s",s);
		switch (s[0])
		{
		       case 'a' :
			   case 'b' :
			   case 'c' :
			   case 'd' :
			   case 'e' :
			   case 'f' :
			   case 'g' :
		 	   case 'h' :
			   case 'i' :
			   case 'j' :
			   case 'k' :
			   case 'l' :
			   case 'm' :
			   case 'n' :
			   case 'o' :
			   case 'p' :
			   case 'q' :
			   case 'r' :
			   case 's' :
			   case 't' :
			   case 'u' :
			   case 'v' :
			   case 'w' :
			   case 'x' :
			   case 'y' :
			   case 'z' :
			   case 'A' :
			   case 'B' :
			   case 'C' :
			   case 'D' :
			   case 'E' :
			   case 'F' :
			   case 'G' :
		 	   case 'H' :
			   case 'I' :
			   case 'J' :
			   case 'K' :
			   case 'L' :
			   case 'M' :
			   case 'N' :
			   case 'O' :
			   case 'P' :
			   case 'Q' :
			   case 'R' :
			   case 'S' :
			   case 'T' :
			   case 'U' :
			   case 'V' :
			   case 'W' :
			   case 'X' :
			   case 'Y' :
			   case 'Z' :
			   case '_' : for (j=1,temp==0;s[j]!='\0';j++)
						  {
			                  switch (s[j])
							  {
			                     case '1' :
			                     case '2' :
			                     case '3' :
			                     case '4' :
			                     case '5' :
			                     case '6' :
			                     case '7' :
			                     case '8' :
			                     case '9' :
			                     case '0' :
		   	                     case 'a' :
			                     case 'b' :
			                     case 'c' :
			                     case 'd' :
			                     case 'e' :
			                     case 'f' :
			                     case 'g' :
		 	                     case 'h' :
			                     case 'i' :
			                     case 'j' :
			                     case 'k' :
			                     case 'l' :
			                     case 'm' :
			                     case 'n' :
			                     case 'o' :
			                     case 'p' :
			                     case 'q' :
			                     case 'r' :
			                     case 's' :
			                     case 't' :
			                     case 'u' :
			                     case 'v' :
			                     case 'w' :
			                     case 'x' :
			                     case 'y' :
			                     case 'z' :
			                     case 'A' :
			                     case 'B' :
			                     case 'C' :
			                     case 'D' :
			                     case 'E' :
			                     case 'F' :
			                     case 'G' :
		 	                     case 'H' :
			                     case 'I' :
			                     case 'J' :
			                     case 'K' :
			                     case 'L' :
			                     case 'M' :
			                     case 'N' :
			                     case 'O' :
			                     case 'P' :
			                     case 'Q' :
			                     case 'R' :
			                     case 'S' :
			                     case 'T' :
			                     case 'U' :
			                     case 'V' :
			                     case 'W' :
			                     case 'X' :
			                     case 'Y' :
			                     case 'Z' :
			                     case '_' :  break;
                                 default : temp=1; break;
							  }
						  } ; break;
			default : temp=1; break;
		  }
		if (temp==0) printf("yes\n");
		else printf("no\n");
		temp=0;
	}

	return 0;
}


int change(char m)
{
 int n;
 switch(m)
  {
   case '0':n=0;break;
   case '1':n=0;break;
   case '2':n=0;break;
   case '3':n=0;break;
   case '4':n=0;break;
   case '5':n=0;break;
   case '6':n=0;break;
   case '7':n=0;break;
   case '8':n=0;break;
   case '9':n=0;break;
   case'A':n=0;break;
     case'B':n=0;break;
     case'C':n=0;break;
     case'D':n=0;break;
     case'E':n=0;break;
     case'F':n=0; break;
     case'G':n=0;break;
     case'H':n=0;break;
     case'I':n=0;break;
     case'J':n=0;break;
     case'K':n=0;break;
     case'L':n=0;break;
     case'M':n=0;break;
     case'N':n=0;break;
     case'O':n=0;break;
     case'P':n=0;break;
     case'Q':n=0;break;
     case'R':n=0;break;
     case'S':n=0;break;
     case'T':n=0;break;
     case'U':n=0;break;
     case'V':n=0;break;
     case'W':n=0;break;
     case'X':n=0;break;
     case'Y':n=0;break;
     case'Z':n=0;break;
     case'a':n=0;break;
     case'b':n=0;break;
     case'c':n=0;break;
     case'd':n=0;break;
     case'e':n=0;break;
     case'f':n=0; break;
     case'g':n=0;break;
     case'h':n=0;break;
     case'i':n=0;break;
     case'j':n=0;break;
     case'k':n=0;break;
     case'l':n=0;break;
     case'm':n=0;break;
     case'n':n=0;break;
     case'o':n=0;break;
     case'p':n=0;break;
     case'q':n=0;break;
     case'r':n=0;break;
     case's':n=0;break;
     case't':n=0;break;
     case'u':n=0;break;
     case'v':n=0;break;
     case'w':n=0;break;
     case'x':n=0;break;
     case'y':n=0;break;
     case'z':n=0;break;
     case'_':n=0;break;
     default:n=1;break;
     }
     return(n);
}
int main()
{
  int n;
  scanf("%d\n",&n);
  char s[1000][20];
  int i,j;
  for(i=0;i<n;i++)
  {
   scanf("%s\n",s[i]);
  }
  for(i=0;i<n;i++)
  {
   int x,y;
   y=0;
   x=strlen(s[i]);
   if(change(s[i][0])==1||(change(s[i][0])==0&&(s[i][0]=='0'||s[i][0]=='1'||s[i][0]=='2'||s[i][0]=='3'||s[i][0]=='4'||s[i][0]=='5'||s[i][0]=='6'||s[i][0]=='7'||s[i][0]=='8'||s[i][0]=='9')))
   {y=1;}
   else
   {
    for(j=1;j<x;j++)
    {
     if(change(s[i][j])==1)
     {y=1;break;}
    }
   }
   if(y==0)
   printf("yes\n");
   else if(y==1)
   printf("no\n");
  }
	return 0;
}


void main()
{
	int i,j,n,m,k;
	char c[100][1000];
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%s",c[i]);
	for(i=1;i<=n;i++)
	{
		for(j=0;j<strlen(c[i]);j++)
			if(c[i][0]>='0'&&c[i][0]<='9')
            {
				printf("no\n");
				goto loop;
			}
			else if(c[i][j]=='_')
				continue;
			else if(c[i][j]>='A'&&c[i][j]<='Z')
				continue;
			else if(c[i][j]>='a'&&c[i][j]<='z')
				continue;
			else if(c[i][j]>='0'&&c[i][j]<='9')
				continue;
			else
			{
				printf("no\n");
				goto loop;
			}
			printf("yes\n");
        loop:;
	}
}


int main()
{
    int n=0,i=0,len=0;
    scanf("%d\n", &n);
    char str[100];
    while(i<n)
    {
        i++;
        fgets(str, 100, stdin);
        len = strlen(str) - 1;
        if(str[0]=='_'||isalpha(str[0]))
            for(int j=0;j<len;j++)
            {
                if(!(str[j]=='_'||isalpha(str[j])||isdigit(str[j])))
                {
                    cout<<"no"<< endl;
                    break;
                }
                else
                    if(j==len-1) cout<<"yes"<<endl;
            }
        else  cout<<"no"<<endl;
    }
    return 0;
}


int main() {
  int n;
  char buf[1024];
  char *tmp;
  int i;
  int ok;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%s", buf);
    ok = 1;
    tmp = buf;
    if (isdigit(*tmp)) {
      ok = 0;
    } else {
      while (*tmp != 0) {
        if (!isalnum(*tmp) && *tmp != '_') {
          ok = 0;
          break;
        }
        ++tmp;
      }
    }
    if (ok == 1)
      printf("yes\n");
    else
      printf("no\n");
  }
  return 0;
}


int main()
{
	int n;
	cin>>n;
	cin.get();
	while(n--){
		char str[100];
		cin.getline(str,100);
		int k=strlen(str),flag=0;
		if(str[0]>='0'&&str[0]<='9')//??????????????
			cout <<"no"<<endl;
		else{
			for(int i=0;i<k;i++){
				if(str[i]>='a'&&str[i]<='z')
					flag++;
				else if(str[i]>='A'&&str[i]<='Z')
					flag++;
				else if(str[i]>='0'&&str[i]<='9')
					flag++;
				else if(str[i]=='_')
					flag++;
				else
					break;
			}
			if (flag==k)
				cout<<"yes"<<endl;
			else
				cout << "no" <<endl;
		}
	}
	return 0;
}


int main()

{
    int n,i,j,point,flag;
    scanf("%d",&n);
char*lab=(char*)malloc(n*20*sizeof(char));
for(i=0;i<n;i++)
    scanf("%s",lab+i*20);
/*for(i=0;i<n;i++)
    puts(lab+i*20);*/
for(i=0;i<n;i++)
{

    for(j=0,flag=0;*(lab+20*i+j)!='\0';j++)
        {
        point=20*i+j;
        if(j==0)
               {
            if (*(lab+point)=='_'||(*(lab+point)>='A'&&*(lab+point)<='Z')||(*(lab+point)>='a'&&*(lab+point)<='z'))
                continue;
                else { //printf("%c\ni is %d\nj is %d\n",*(lab+point),i,j);
                        flag=1;
                        break;
                     }
                }
            else
                if( !((*(lab+point)>='A'&&*(lab+point)<='Z')||(*(lab+point)>='a'&&*(lab+point)<='z'))&& *(lab+point)!='_'   &&  !(*(lab+point)>='0'&&*(lab+point)<='9'))
                    {//printf("%c\ni is %d\nj is %d\n",*(lab+point),i,j);
                        flag=1;
                        break;
                    }
        }
    // printf("flag is %d",flag);
     if(flag)
        printf("no\n");
     else
        printf("yes\n");
}
return 0;
}


int main() {
	int n;
	cin >> n;
	while (n--) {
		char str[32];
		cin >> str;
		int i, l = strlen(str);
		if ('0'<=str[0]&&str[0]<='9') {
			cout << "no\n";
			continue;
		}
		for (i = 0; i < l; ++i) {
			if ('0'<=str[i]&&str[i]<='9') continue;
			if ('a'<=str[i]&&str[i]<='z') continue;
			if ('A'<=str[i]&&str[i]<='Z') continue;
			if (str[i]=='_') continue;
			break;
		}
		if (i == l) {
			cout << "yes\n";
		} else {
			cout << "no\n";
		}
	}
}


int main(){
    int n,i;char a[50]={0};
    cin>>n;
    while(n--){
        cin>>a;
        if(isdigit(a[0])){
            cout<<"no"<<endl;
            continue;
        }
        for(i=0;a[i]!=0;++i){
            if(a[i]==95||isupper(a[i])||islower(a[i])||isdigit(a[i]))
                continue;
            else break;
        }
        a[i]==0?cout<<"yes"<<endl:cout<<"no"<<endl;
    }
}


int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		{
		char c[21]={0};
		scanf("%s",c);
		int len=strlen(c),judge=0;
		if(!isalpha(c[0])&&c[0]!='_')
			{
			printf("no\n");
			judge=1;
			}
		else
			{
			for(int j=1;j<len;j++)
				{
				if(!isalnum(c[j])&&c[j]!='_')
					{
					printf("no\n");
					judge=1;
					break;
					}
				}
			}
		if(judge==0)
			printf("yes\n");
		}
}


int main()
{
	int n,len,flag;
	char str[21];
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>str;
		//cin.getline(str,21);
		len=strlen(str);
		for(int j=0;j<len;j++)
		{
			if(j==0)
			{
			if(str[0]=='_'||(str[0]>='a'&&str[0]<='z')||(str[0]>='A'&&str[0]<='Z'))
				flag=0;
			else
				flag=1;
			}
			else if(str[j]=='_'||(str[j]>='a'&&str[j]<='z')||(str[j]>='A'&&str[j]<='Z')||(str[j]>='0'&&str[j]<='9'))
				flag=flag;
			else
				flag=1;
		}
		if(flag==0)
				cout<<"yes"<<endl;
			else
				cout<<"no"<<endl;
	}
	return 0;
}


int dx(char c)
{if ((c>='A')&&(c<='Z')) return 7;
 else return 0;
}
int xx(char c)
{if ((c>='a')&&(c<='z')) return 7;
 else return 0;
}
int xhx(char c)
{if (c=='_') return 7;
 else return 0;
}
int num(char c)
{if ((c>='0')&&(c<='9')) return 7;
 else return 0;
}
int head(char c)
{return dx(c)+xx(c)+xhx(c);}
int body(char c)
{return dx(c)+xx(c)+xhx(c)+num(c);}
int main()
{int i,j,k,l,flag=7;
 char c[1000]={' '};
 scanf("%d\n",&k);
 for (j=0;j<k;j++)
 {	scanf("%s",c);
	if (head(c[0])==0) printf("no");
	 else {for (i=strlen(c)-1;i>0;i--)
			    if (body(c[i])==0) flag=0;
		   if (flag==7) printf("yes");
		   if (flag==0) printf("no");
		   flag=7;
		   }
	 putchar(10);
 }
 return 7;
}


int main(int argc, char* argv[])
{
	int i, j, n, t, flag;
	char syx[21];
	scanf("%d", &n);
	for (i=0; i<n; i++)
	{
		flag = 1;
		scanf("%s", syx);
		t = strlen(syx);
		for (j=0; j<t; j++)
		{
			if(syx[j]==95)
				continue;
			else if(j==0 && syx[j] < 65 || syx[j] > 90 && syx[j] < 94 || syx[j] > 96 && syx[j] < 97 || syx[j]>122)
			{
				flag = 0;
				break;
			}
			else if(syx[j] < 48 || syx[j]>57 && syx[j] < 65 || syx[j] > 90 && syx[j] <97 || syx[j] > 122)
			{
				flag = 0;
				break;
			}
		}
		if (flag == 0)
			printf("no\n");
		else
			printf("yes\n");
	}

	return 0;
}


int judgechar(char x){
	if(x>47&&x<58){return 0;}
	if(x>64&&x<91){return 0;}
	if(x>96&&x<123){return 0;}
	if(x>96&&x<123){return 0;}
	if(x==95){return 0;}
	return 1;}
int judgebegin(char x){
	if(x>64&&x<91){return 0;}
	if(x>96&&x<123){return 0;}
	if(x>96&&x<123){return 0;}
	if(x==95){return 0;}
	return 1;}
int main (){
	int all,i,p,len,ok;
	char input[21];
	scanf("%d",&all);
	for(i=0;i<all;i++){
		scanf("%s",input);
		len=strlen(input);
		ok=1;
		if(judgebegin(input[0])){

			ok=0;}
		for(p=1;p<len;p++){if(judgechar(input[p])){ok=0;}}
		if(ok==0){printf("no\n");}
		if(ok==1){printf("yes\n");}
	}

return 0;}


int main()
{
	char str[100][20];
	char sample1[54];
	char sample2[64];
	int n;
	int i,j,k,tmp1,tmp2,tmp3,length;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",str[i]);
	}
	for(i=0;i<26;i++)
		sample1[i]=i+65;
	for(;i<52;i++)
		sample1[i]=i+71;
	sample1[53]=95;
	for(i=0;i<53;i++)
		sample2[i]=sample1[i];
	for(;i<63;i++)
		sample2[i]=i-5;
	sample2[63]=95;
	for(i=0;i<n;i++)
	{
		length=strlen(str[i]);
		for(j=0,tmp1=1;j<54;j++)
		{
			if(str[i][0]==sample1[j])
			{
				tmp1=0;
				break;
			}
		}
		if(tmp1==1)
		{
			printf("no\n");
			continue;
		}
		for(j=1,tmp3=1;j<length;j++)
		{
			for(k=0,tmp2=1;k<64;k++)
			{
				if(str[i][j]==sample2[k])
				{
					tmp2=0;
					break;
				}
			}
			if(tmp2==1)
			{
				printf("no\n");
				tmp3=0;
			}
			else
			{
				continue;
			}
			if(tmp3==0)
				break;
		}
		if(j==length)
			printf("yes\n");
	}
	return 0;
}


int main()
{
    int n;
	char str[500];
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%s", str);
		if ((str[0] < 'a' || str[0] > 'z') && (str[0] < 'A' || str[0] > 'Z') && (str[0] != '_'))
		{
			printf("no\n");
			continue;
		}
		else if(strlen(str) == 1)
		{
			printf("yes\n");
		}
		else
		{
			int len = strlen(str);
			int j;
			for (j = 1; j < len; j++)
			{
				if ((str[j] < 'a' || str[j] > 'z') && (str[j] < 'A' || str[j] > 'Z') && (str[j] != '_') && (str[j] < '0' || str[j] > '9'))
					break;
			}
			if (j == len)
				printf("yes\n");
			else
				printf("no\n");
		}
	}
	return 0;
}


int main(){
	int len,judge,i,all,p;
	char input[21];
	scanf("%d",&all);
	for(p=0;p<all;p++){
		scanf("%s",input);
		len=strlen(input);
		judge=0;
		if(input[0]>='a'&&input[0]<='z'){judge=1;}
		if(input[0]>='A'&&input[0]<='Z'){judge=1;}
		if(input[0]=='_'){judge=1;}
		if(input[0]>='9'&&input[0]<='1'){judge=0;}
		if(input[0]=='0'){judge=0;}
		if(judge==0){printf("no\n");continue;}
		for(i=1;i<len;i++){
			judge=0;
			if(input[i]>='a'&&input[i]<='z'){judge=1;}
			if(input[i]>='A'&&input[i]<='Z'){judge=1;}
			if(input[i]>='1'&&input[i]<='9'){judge=1;}
			if(input[i]=='0'){judge=1;}
			if(input[i]=='_'){judge=1;}
			if(judge==0){printf("no\n");break;}

	}
	if(judge==0){continue;}
	printf("yes\n");

	}

return 0;
}


char s[1000];
int main(){
	int T,i;
	scanf("%d",&T);
	while (T--){
		scanf("%s",s);
		if (isalpha(s[0])||s[0]=='_'){
			for (i=1;s[i];i++){
				if (!isalpha(s[i])&&!isdigit(s[i])&&s[i]!='_'){
					break;
				}
			}
			if (s[i]){
				puts("no");
			}else puts("yes");
		}else
			puts("no");
	}
}


int judgeChar(char c);
int judgeChars(char * c, int n);
int judgeChars(char * c, int n)
{
	int i;
	if((!judgeChar(c[0])) || isdigit(c[0]))
		return 0;
	for(i=1; i<n; i++)
		if(!judgeChar(c[i]))
			return 0;
	return 1;
}

int judgeChar(char c)
{
	if(isalnum(c) || c == '_')
		return 1;
	return 0;
}

int main()
{
	int i, n, result[100];
	char c[50];
	scanf("%d", &n);
	gets(c);
	for(i=0; i<n; i++)
	{
		gets(c);
		result[i] = judgeChars(c, strlen(c));
	}

	if(result[0])
			printf("yes");
	else
			printf("no");

	for(i=1; i<n; i++)
	{
		if(result[i])
			printf("\nyes");
		else
			printf("\nno");
	}
	return 0;
}


int com(char sz_);
int com1(char sz_1);
int main()
{
    char sz[20][21];
    char sz_;
    char sz_1;
    int n,HH,JJ;
    scanf("%d",&n);
    for(HH=0;HH<n;HH++)
    {
        scanf("%s",sz[HH]);
    }

    for(HH=0;HH<n;HH++)
    {
      JJ=0;

      sz_=sz[HH][JJ];
      if(com(sz_)==0)
        {
            printf("no\n");
            continue;
        }
        for(JJ=1;sz[HH][JJ]!='\0';JJ++)
           {
            sz_1=sz[HH][JJ];
            if(com1(sz_1)==0)
                 {
                printf("no\n");
               break;

                  }
             }
  if(sz[HH][JJ]=='\0')
{
            printf("yes\n");

}
    }

   return 0;
}

int com(char sz_){
    int result;
    if(('a'<=sz_&&sz_<='z')||sz_=='_'||('A'<=sz_&&sz_<='Z'))
    {
        result=1;
    }
    else{
        result=0;
    }
    return result;
                   }

int com1(char sz_1)
{
    int result1;
    if(('a'<=sz_1&&sz_1<='z')||sz_1=='_'||('A'<=sz_1&&sz_1<='Z')||('0'<=sz_1&&sz_1<='9'))

    {
        result1=1;
    }
    else{
        result1=0;
    }
    return result1;
}


int is_legal(char name[20], int length);
int first_lg(char trig);
int illegal_sym(char name[20], int length);
main()
{
      int n;
      int length;
      int i;
      char name[100][20];
      int ok[100];

      scanf("%d", &n);

      for(i = 0;i <= n - 1;i ++)
      {
            scanf("%s", &name[i]);
            length = strlen(name[i]);

            ok[i] = is_legal(name[i], length);
      }

      for(i = 0;i <= n - 1;i ++)
      {
       if(ok[i]) printf("yes\n"); else printf("no\n");
       }
}

int is_legal(char name[20], int length)
{
    //printf("First char:%d\n", first_lg(name[0]));
    //printf("General:%d\n", illegal_sym(name, length));
    if(!first_lg(name[0])) return FALSE;
    if(!illegal_sym(name, length)) return FALSE;
    return TRUE;
}

int first_lg(char trig)
{
    int is1, is2, is3;
    char ch;

    ch = (toupper(trig));

    is1 = (ch > 'Z');
    is2 = (ch < 'A');

    if(trig == '_') return TRUE;
    if(is1 + is2 != 0) return FALSE;
    return TRUE;
}

int illegal_sym(char name[20], int length)
{
    int i;
    char ch;
    int is_al, is_num, is_dash;
    int is;
    for(i = 0;i <= length - 1;i ++)
    {
          ch = toupper(name[i]);
          is_al = (ch <= 'Z') && (ch >= 'A');
          is_num = (ch <= '9') && (ch >= '0');
          is_dash = (ch == '_');
          is = (is_al || is_num || is_dash);

          if(!is)
          {
                 //printf("Bug section:%d\nchar:%c\n", i + 1, ch);
                 return FALSE;
          }
    }
    return TRUE;
}


char juzi[1000];
int islegal(char juzi[],int n)
{
	int q;
	if((juzi[0]>'z'||juzi[0]<'a')&&(juzi[0]>'Z'||juzi[0]<'A')&&juzi[0]!='_')
		return 0;
	for(q=1;q<n;q++)
	{
		if((juzi[q]>'z'||juzi[q]<'a')&&(juzi[q]>'Z'||juzi[q]<'A'))
		{
			if(juzi[q]>'9'||juzi[q]<'0')
			{
				if(juzi[q]!='_')
					return 0;
			}
		}
	}
	return 1;
}

void main()
{
	int n;
	char m[6];
	gets(m);
	n=atoi(m);
	while(n--)
	{
		gets(juzi);
		int len=strlen(juzi);
		if(islegal(juzi,len)==1)
			printf("yes\n");
		else
			printf("no\n");
	}
}


int main()
{
	int n;

	cin >> n;
	for(int i=0; i<n; i++) {
		char str[100];
		cin >> str;
		if(strlen(str) > 20) {
			cout << "no" << endl;
			continue;
		}
		int j;
		if(str[0] >= '0' && str[0] <= '9') {
			cout << "no" << endl;
			continue;
		}
		for(j=0; j<strlen(str); j++) {
			if(str[j] >= 'A' && str[j] <= 'Z' ||
				str[j] >= 'a' && str[j] <= 'z' ||
				str[j] >= '0' && str[j] <= '9' ||
				str[j] == '_' ) {
				continue;
			} else {
				cout << "no" << endl;
				break;
			}
		}
		if(j == strlen(str)) cout << "yes" << endl;
	}

	return 0;
}


int decide(char k)
{
	if ((isdigit(k)==0)&&(isalpha(k)==0)&&(k!=95))
		return 0;
	else
		if (isdigit(k)==1)
			return 2;
		else
			return 1;
}

int main()
{
	int n,j,m,i;
	char a[500][20]={0};
	scanf("%d\n",&n);
	for (i=1;i<=n;i++)
	{
		gets(a[i]);
		m=strlen(a[i]);
		if (decide(a[i][0])!=1)
		{
			printf("no\n");
			continue;
		}
		else
		{
			j=1;
			while (j<m)
			{
				if (decide(a[i][j])==0)
					j=m+2;
				else
					j=j+1;
			}
			if (j==m)
				printf("yes\n");
			else
				printf("no\n");
		}
	}
return 0;
}


int main()
{
	int panduan(char *s,int len);
	char shuru[30],*s;
	int i,n,len;
	gets(shuru);
	n=atoi(shuru);
	for(i=0;i<n;i++){
		gets(shuru);
		len=strlen(shuru);
		s=shuru;
		if(panduan(s,len))
			printf("yes\n");
		else
			printf("no\n");
	}
	return 0;
}
int panduan(char *s,int len)
{
	int i;
	for(i=0;i<len;i++){
		if(*s!='_'&&(*s<'a'||*s>'z')&&(*s<'A'||*s>'Z'))
			return 0;
		if(*(s+i)!='_'&&(*(s+i)<'a'||*(s+i)>'z')&&(*(s+i)<'A'||*(s+i)>'Z')&&(*(s+i)>'9'||*(s+i)<'0'))
			return 0;
	}
	return 1;
}


int tag(char x);
void main()
{
	char a[30];
	int n,i=1,j,l;
	scanf("%d\n",&n);
	while(i<=n)
	{
		gets(a);
		j=0;
		l=strlen(a);
		while(a[j])
		{
			if(tag(a[j])==2) break;
			j++;
		}
		if(j==l&&tag(a[0])==1) printf("yes\n");
		else printf("no\n");
		i++;
	}
}
int tag(char x)
{
	if(x>='0'&&x<='9') return(0);
	else if(x>='A'&&x<='Z') return(1);
	else if(x>='a'&&x<='z') return(1);
	else if(x=='_') return(1);
	else return(2);
}


int main()
{
    int n,i;
    scanf("%d",&n);
    for(i = 0;i < n;i++)
    {
        char input[100];
        int len,j = 0;
        scanf("%s",input);
        len = strlen(input);
        if(input[0] == '_' || (input[0]>='a' && input[0]<='z') || (input[0]>='A' && input[0]<='Z'))
        {
            for(j = 1;j < len;j++)
                 if(!(input[j] == '_' || (input[j]>='a' && input[j]<='z') || (input[j]>='A' && input[j]<='Z') || (input[j] >= '0' && input[j] <= '9')))
                    break;
        }
        if(j == len)
            printf("yes\n");
        else
            printf("no\n");
    }
    return 0;
}


int isidentifor(const char* name)
{
    const char *p = name;
    char ch = *p;
    if ((ch < 'A' || ch > 'Z') && (ch < 'a' || ch > 'z') && (ch != '_'))
    {
        return 0;
    }
    for (p++; *p; p++)
    {
        ch = *p;
        if ((ch < 'A' || ch > 'Z') && (ch < 'a' || ch > 'z') && (ch != '_') && (ch < '0' || ch > '9'))
        {
            return 0;
        }
    }
    return 1;
}

int main()
{
    char name[33];
    int n;

    scanf("%d", &n);
    while (n--)
    {
        scanf("%s", name);

        if (isidentifor(name))
        {
            printf("yes\n");
        }
        else
        {
            printf("no\n");
        }
    }
    return 0;
}


int main(){
	char str[MAX+1];
	int n,i,j,len;
gets(str);
n=atoi(str);
  for(i=0;i<n;i++){
	  gets(str);
 len=strlen(str);
	  if((str[0]<='z'&&str[0]>='a')||(str[0]<='Z'&&str[0]>='A')||str[0]=='_'){
	   for(j=1;j<len;j++){
		   if((str[j]<='z'&&str[j]>='a')||(str[j]<='Z'&&str[j]>='A')||(str[j]=='_')||(str[j]<='9'&&str[j]>='0'))
			   continue;
		   else
			   break;
	   }
	   if(j==len)
		   printf("yes\n");
		else
printf("no\n");
	  }
	  else
printf("no\n");
  }

	return 0;
}


void main()
{
    int n,i,k,j,flag;
    char key[37][20]={"int","char","float","double","short","long","unsigned","struct","union","enum","auto","extern","register","static","typedef","goto","return","sizeof","break","continue","if","else","do","while","for","switch","case","default","void","entry","include","define","undef","ifdef","ifndef","endif","line"};
    char a[100];
    scanf("%d",&n);
    for (i=0;i<n;i++)
    {
    	flag=0;
    	scanf("%s",a);
    	k=strlen(a);

    	if (a[0]>122||(a[0]>90&&a[0]<97&&a[0]!=95)||a[0]<65) flag=1;

    	for (j=1;j<k;j++)
    	{
    		if (a[j]<48||a[j]>122||(a[j]>57&&a[j]<65)||(a[j]>90&&a[j]<97&&a[j]!=95)) flag=1;
    	}

    	for (j=0;j<37;j++)
    	{
    		if (!strcmp(key[j],a))  flag=1;
    	}

    	if (flag==1)
    	{
    		printf("no\n");
    	}
    	else printf("yes\n");
    }
}


int judge(char *zfc)
{
	char *p;
	p=zfc;
	for(;*p!='\0';p++){
		if(*p=='_'||('A'<=*p&&*p<='Z')||('a'<=*p&&*p<='z')||('0'<=*p&&*p<='9'&&p!=zfc)){
			continue;
		}else{
			return 0;
		}
	}
	return 1;
}
int main()
{
	int i;
	char z[3];
	gets(z);
	int n=atoi(z);
	for(i=0;i<n;i++){
		char zfc[81];
		gets(zfc);
		if(judge(zfc)){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}
	return 0;
}


int main()
{
	int n,i,j,length,flag;
	char str[21];
	cin>>n;
	cin.get();
	for(j=0;j<n;j++)
	{
		cin.getline(str,21);
		length=strlen(str);
	    flag=0;
		if((str[0]>='A'&&str[0]<='Z')||(str[0]>='a'&&str[0]<='z')||(str[0]=='_'))
		{
			flag=1;
			for(i=1;i<length;i++)
			{
				if((str[i]>='A'&&str[i]<='Z')||(str[i]>='a'&&str[i]<='z')||(str[i]=='_')||(str[i]>='0'&&str[i]<='9')) flag++;
				else
				{
					cout<<"no"<<endl;
					break;
				}
			}
			if(flag==length) cout<<"yes"<<endl;
		}
		else cout<<"no"<<endl;
	}
	return 0;
}


void main()
{
	int n,first=1,no=0;
	char c;
	scanf("%d",&n);
	getchar();
	for(;n>0;n--){
		c=getchar();
		while(c!='\n'){
			if(first){
				if(!(isalpha(c)||c=='_')){
					no=1;
					break;
				}
				else first=0;
			}
			else{
				if(!(isalnum(c)||c=='_')){
					no=1;
					break;
				}
			}
			c=getchar();
		}
		if(no){
			printf("no\n");
			while(c!='\n') c=getchar();
		}
		else printf("yes\n");
		first=1;
		no=0;
	}

}


int main()
{

    int n,i,j,flag=0,length=0;
    char a[100];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s",a);
        length=strlen(a);
        if('0'<=a[0]&&a[0]<='9') flag=1;
        for(j=0;j<length;j++)
        {
            if('a'<=a[j]&&a[j]<='z') continue;
            else if('A'<=a[j]&&a[j]<='Z') continue;
            else if('0'<=a[j]&&a[j]<='9') continue;
            else if(a[j]=='_') continue;
            else flag=1;
        }
        if(flag==0) printf("yes\n");
        else printf("no\n");
        flag=0;
    }
    return 0;
}


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

int main()
{
	int n;
	scanf("%d",&n);
	int i;
	for(i=1;i<=n;++i)
	{
		int a[21],j=0;
		int m;
		scanf("%d",&m);
                  if(m==0)
		{
			printf("60\n");
			continue;
		}
		for(j=1;j<=m;++j) scanf("%d",&a[j]);
		int t[21];
		for(j=1;j<=m;++j)
		{
			t[j]=a[j]+3*j;
			if(t[j]>=63)
			{
				printf("%d\n",a[j-1]+60-t[j-1]);
				break;
			}
			else if(t[j]>=60)
			{
				printf("%d\n",a[j]);
				break;
			}
		}
		if(j==m+1) printf("%d\n",a[m]+60-t[m]);
	}
	return 0;
}


int main()
{
	int n;
	scanf("%d",&n);
	int *sz=(int*)malloc(sizeof(int)*n);
	int i,m,j,k;
	int *save;
	for(i=0;i<n;i++)
	{
		sz[i]=0;
		scanf("%d",&m);
		if(m==0)
		{
			sz[i]=60;
			continue;
		}
		save=(int*)malloc(sizeof(int)*m);
		for(j=0;j<m;j++)
		{
			scanf("%d",&save[j]);
		}
		for(j=0;j<m;j++)
		{
			k=save[j]+3*j;
			if(k>=60)
			{
				sz[i]=60-3*j;
				break;
			}
			if(k<60 && k>=57)
			{
				sz[i]=k-3*j;
				break;
			}
		}
		if(sz[i]==0)
		{
			sz[i]=60-3*m;
		}
	}
	for(i=0;i<n;i++)
	{
		printf("%d\n",sz[i]);
	}
	free(sz);
	free(save);
	return 0;
}


int main()
{
	int n;
	cin>>n;
	for(int o=1;o<=n;o++)
	{
		int m;
		cin>>m;
		int stop[m+1],TimeNow=0,Num=0;
		for(int x=1;x<=m;x++) {cin>>stop[x];}
		if(m==0) cout<<60<<endl;
		else
		{
		  for(int x=1;x<=m;x++)
		  {
		    while(Num<stop[x])
		    {
		    	TimeNow++;
		    	Num++;
		    	if(TimeNow>=60) {break;}
		    }
		    TimeNow+=3;
			if(TimeNow>=60) break;
		  }
		  if(TimeNow<=60){Num+=60-TimeNow;}
		  cout<<Num<<endl;
	    }
	}
	return 0;
}


int main()
{
	int time,i,n,broken,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&broken);
		if(broken==0)
		{
			printf("60\n");
		}
		else
		{
		int *num=(int*)malloc(sizeof(int)*broken);
		for(j=0;j<broken;j++)
		{
			scanf("%d",&num[j]);
		}
		for(j=broken-1;j>=0;j--)
		{
			time=num[j]+(j+1)*3;
			if(time<60)
			{
				printf("%d\n",60-(j+1)*3);
				break;
			}
			else if(time<63)
			{
				printf("%d\n",num[j]);
				break;
			}
		}
		free(num);
		}
	}
	return 0;
}


/*
 * tiaoshenjishu.cpp
 *
 *  Created on: 2011-12-21
 *      Author: Administrator
 */
int main()
{
	int n,broke,times,last;
	cin>>n;
	while(n--)
	{
		cin>>broke;
		last=0;
		while(broke--)
		{
			cin>>times;
			if(last+times<60)
			{
				if(last+times+3<60)
				{
					last=last+3;
				}
				else
				{
					last=60-times;
				}
			}
		}
		cout<<60-last<<endl;
	}
	return 0;
}


int tiaosheng(int m,int *a);
int main()
{
    int *a,i,j,k,l,m,n;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
                   // k=l=0;
                    scanf("%d",&m);
                   if(m==0)
                   {
                           printf("60\n");continue;
                   }
                    a=(int*)malloc(m*sizeof(int));
                    for(j=0;j<m;j++)scanf("%d",&a[j]);
                    printf("%d\n",tiaosheng(m,a));
    }
    return 0;
}
int tiaosheng(int m,int *a)
{
    int i,n;
    for(i=m-1;i>=0;i--)
    {
                    if((a[i]+3*(i+1))<=60)
                    {
                                          n=60-3*(i+1);break;
                    }
                    else if((a[i]+3*i)<=60)
                    {
                                            n=a[i];break;
                    }
    }
    return n;
}


int main(){
	int n,i,m,j,mistake[100],k,result[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&m);
		result[i]=60;
		for(j=0;j<m;j++){
			scanf("%d",&mistake[j]);
		}
		for(j=0;j<m;j++){
			for(k=0;k<=3;k++){
				if(mistake[j]+3*j+k>=60){
					result[i]-=(k+1);
					break;
				}
			}
			if(result[i]!=60){
				result[i]++;
				break;
			}
		}
		result[i]-=3*j;
	}
	for(i=0;i<n;i++){
		printf("%d\n",result[i]);
	}
	return 0;
}


/*
 * ????.cpp
 *
 *  Created on: 2011-12-30
 *      Author: ???
 */

int main(){
	int num;cin>>num;
	while(num>0){
		num--;
		int badtimes,total=60,i;
		cin>>badtimes;
		if(badtimes==0)cout<<60<<endl;
		else{
			while(badtimes>0){
				badtimes--;
				cin>>i;
				if(total<i)continue;
				else if(total<i+3)total=i;
				else total-=3;
			}
			cout<<total<<endl;
		}
	}
	return 0;
}


int main(int argc, char* argv[])
{
	int i,j,n,m,a;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&m);
		a=0;
		if(m==0){
			printf("60\n");
			continue;
		}
		for(j=0;j<m;j++){
			scanf("%d",&a);
			if(a+j*3<57)
				continue;

			if(a+j*3<=63){
				printf("%d\n",a);
				break;
			}else{
				printf("%d\n",60-3*j);
				break;
			}
		}
		if(j == m)
			printf("%d\n",60-3*m);
	}
	return 0;
}


int main()
{
	int n,m,i,j,k,time,sum;
	cin>>n;
	int x[n+1];
	for(i=1;i<=n;i++)
	{
		time=0,sum=0;
		cin>>m;
		int a[m+1];
		for(j=1;j<m+1;j++)
		{
			cin>>a[j];
		}
			for(j=1;j<m+1;j++)
		{
			time=a[j]+3*j;
			if(time<=63)
			{
				sum=a[j];
			}
			if(time>=60&&time<63)
			{break;
			}
			else if(time>63)
			{
				time=a[j-1]+3*(j-1);
				sum=a[j-1]+60-time;
				time=a[j]+3*j;
			    break;
			}
		}

		if(time<60)
		{
			sum=sum+60-time;
		}
		x[i]=sum;
	}
	for(i=1;i<=n;i++)
	{
		cout<<x[i]<<endl;
	}
	return 0;
}


int main()

{
    int count;
    int sum = 0;
    int num;
    int n;
    int i;
    int j, k, l;
    int a[1000];
    cin >> count;
    for(l = 1; l <= count; l++)
    {
          sum = 0;
          cin >> n;
          if (n == 0)
          {
              cout << "60" <<endl;
              continue;
          }
          for (i = 0; i <= 999; i++)
          {
              a[i] = 1;
          }
          for (i = 0;i < n; i++)
          {
              cin >> num;
              a[num + 1 + 3 * i] = 0;
              a[num + 2 + 3 * i] = 0;
              a[num + 3 + 3 * i] = 0;
          }
          for (i = 1; i <= 60; i++)
          {
              sum = sum + a[i];
          }
          cout << sum <<endl;
    }
    return 0;
}


int main()
{
	int n,bad[10],badnum[10],i,j,k,time,goodnum[10];
	cin >>n;
	for (j=0;j<n;j++)
	{
		cin >>bad[j];
		if (bad[j]==0)
			goodnum[j]=60;
		for (i=0;i<bad[j];i++)
		{
			cin >>badnum[i];
		}
		for (i=0;i<bad[j];i++)
		{
			time=badnum[i]+3*(i+1);
			if (time>=60 && badnum[i]+3*i<60)
			{
				goodnum[j]=badnum[i];
				break;

			}
			if (badnum[i]+3*i>=60)
			{
				goodnum[j]=60-3*i;
				break;
			}
			else if (i==bad[j]-1)
				goodnum[j]=60-3*(i+1);

		}

	}

	for (j=0;j<n;j++)
	{
		cout <<goodnum[j]<<endl;
	}
	return 0;
}


int min(int a, int b)
{
	if (a<b) return a;
	else return b;
}

int main()
{
	int n,m,s,t;
	cin>>n;
	for (int i=1; i<=n; ++i)
	{
		cin>>m;
		s=60;
		for (int j=1; j<=m; ++j)
		{
			cin>>t;
			t+=j+j+j-3;
			if (t<=60) s-=min(3,60-t);
		}
		cout<<s<<endl;
	}
	return 0;
}


int main()
{
	int population,m;
	int num[10];
	int i,j;
	int time=0,duandian=1,sum=0;
	scanf("%d",&population);

	for(i=0;i<population;i++)
	{
		scanf("%d",&m);
		if(m==0)
		{
			printf("60\n");
			continue;
		}
		for(j=0;j<m;j++)
		{
			scanf("%d",&num[j]);
		}
		time=num[m-1]+3*m;
		if(time<=60)
		{
			sum=60-3*m;
		}
		else
		{
			time=num[0]+3;
			for(j=1;j<m;j++)
			{
				time=time-num[j-1]+num[j];
				if(time>60)
				{
					sum=60-3*duandian;
					break;
				}
				time+=3;
				if(time>=60)
				{
					sum=time-3-3*duandian;
					break;
				}
				duandian++;
			}
		}
		printf("%d\n",sum);
		sum=0;
		time=0;
		duandian=1;
	}
	return 0;
}


/*
 * tiaosheng.cpp
 *
 *  Created on: 2011-12-23
 *      Author: 11161
 */

int main()
{
	int n;
	cin>>n;
	for(int j=1;j<=n;j++)
	{
		int m;
		cin>>m;
		if(m==0){cout<<60<<endl;continue;}
		int times,sum1=0,sum2=0,w=0;int i=1;
		for(;i<=m;i++)
		{
			cin>>times;
			sum1=3*(i-1)+times;sum2=times;
			if(sum1>57)
			{
			if(sum1>60){cout<<60-(i-1)*3<<endl;}
			else{ cout<<times<<endl;}
			w=1;break;}	//sum1=sum1+3;
		}
		if(w==0){
			if(times>57){cout<<times<<endl;}
		else cout<<60-m*3<<endl;}
		else
		{
			for(int j=i+1;j<=m;j++)
			{
				cin>>times;
			}

		}
	}
	return 0;
}


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

int main()
{
	int n = 0;
	int cut[100] = {0};
	int sum[100][100] = {0};
	int num = 0;
	int i = 0;
	int t = 0;
	int time1 = 0;
	int time2 = 0;
	int q = 0;

	cin >> n;

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

		if( cut[i] == 0)
			continue;

		else
			for( t = 1;t <= cut[i];t ++ )
			{
				cin >> sum[i][t];

			}
	}

	for( i = 1;i <= n;i++ )
	{
		q = cut[i];

		if( cut[i] == 0)
		{
			num = 60;
			cout << num << endl;
		}

		else
			for( t = 1; t <= q;t++ )
			{
				time1 = sum[i][t] + 3 * ( t - 1 );
				time2 = time1 + 3;

				if( t == q && time2 <= 60 )
				{
					num = 60 - q * 3;
					cout << num << endl;
				}

				if( time1 <= 60 && time2 > 60 && time2 <= 63 )
				{
					num = sum[i][t];
					cout << num << endl;
					break;
				}

				if( time1 > 60 )
				{
					num = 60 - 3 * ( t - 1 );
					cout << num << endl;
					break;
				}

			}

	}

	return 0;

}


int aa[20];

int main()
{
    //freopen("1.in","r",stdin);
    //freopen("1.out","w",stdout);
    int n,m;
    cin>>n;
    for(int i=0;i<n;i++)
    {
            cin>>m;
            for(int i=0;i<m;i++)
              cin>>aa[i];
            if(m==0)
            {
                     cout<<"60"<<endl;
                     continue;
            }
            for(int j=0;j<m;j++)
            {
                    if((aa[j]+3*j)>=57 && (aa[j]+3*j)<=60)
                    {cout<<aa[j]<<endl; break;}
                    if((aa[j]+3*j)>60)
                    {
                                      int x=60-3*j;
                                      cout<<x<<endl;
                                      break;
                    }
                    else if(j==m-1)
                    {cout<<60-3*m<<endl;break;}
            }

    }
    return 0;
}


int main(){
	int i,n,m,x[110],ctr,time;
	scanf("%d",&n);
	while(n--){
		ctr=0;
		time=0;
		scanf("%d",&m);
		for(i=1;i<=m;i++){
			scanf("%d",&x[i]);
			if(time+x[i]-ctr<=60)
			{
				time+=x[i]-ctr+3;
				ctr=x[i];
			}
		}
		if(time<60)
			ctr+=60-time;
		printf("%d\n",ctr);
	}
	return 0;
}


int main()
{
	int n;
	cin>>n;
	int k;
	int a[61];
	while(n--)
	{
		cin>>k;
		if(k==0)  {cout<<"60\n";continue;}
		for(int i=1;i<=k;i++)
			cin>>a[i];
		int num=0;
		for(int i=k;i>=1;i--)
		{
			if( a[i]+i*3-3>60 ) continue;
			if(a[i]+i*3>=60) {num=a[i];break;}
			else {num=60-i*3;break;}
		}
		cout<<num<<endl;
	}
  return 0;
}