There is an old tradition of keeping 4 boxes of candies in the house in Cyberland. The numbers of candies are special if their arithmetic mean, their median and their range are all equal. By definition, for a set {x1, x2, x3, x4} (x1 ≤ x2 ≤ x3 ≤ x4) arithmetic mean is , median is  and range is x4 - x1. The arithmetic mean and median are not necessary integer. It is well-known that if those three numbers are same, boxes will create a "debugging field" and codes in the field will have no bugs.For example, 1, 1, 3, 3 is the example of 4 numbers meeting the condition because their mean, median and range are all equal to 2.Jeff has 4 special boxes of candies. However, something bad has happened! Some of the boxes could have been lost and now there are only n (0 ≤ n ≤ 4) boxes remaining. The i-th remaining box contains ai candies.Now Jeff wants to know: is there a possible way to find the number of candies of the 4 - n missing boxes, meeting the condition above (the mean, median and range are equal)?

The first line of input contains an only integer n (0 ≤ n ≤ 4). The next n lines contain integers ai, denoting the number of candies in the i-th box (1 ≤ ai ≤ 500).

In the first output line, print "YES" if a solution exists, or print "NO" if there is no solution. If a solution exists, you should output 4 - n more lines, each line containing an integer b, denoting the number of candies in a missing box. All your numbers b must satisfy inequality 1 ≤ b ≤ 106. It is guaranteed that if there exists a positive integer solution, you can always find such b's meeting the condition. If there are multiple answers, you are allowed to print any of them. Given numbers ai may follow in any order in the input, not necessary in non-decreasing. ai may have stood at any positions in the original set, not necessary on lowest n first positions.

NoteFor the first sample, the numbers of candies in 4 boxes can be 1, 1, 3, 3. The arithmetic mean, the median and the range of them are all 2.For the second sample, it's impossible to find the missing number of candies.In the third example no box has been lost and numbers satisfy the condition.You may output b in any order.

#include <stdio.h>

#define MIN(A, B) (A < B ? A : B)
#define MAX(A, B) (A > B ? A : B)

int main() {
	int min, max, med, n, a, b, c, d;

	scanf("%d", &n);
	switch (n) {
		case 0:
			printf("YES\n1\n1\n3\n3\n");
			break;
		case 1:
			scanf("%d", &a);
			printf("YES\n%d\n%d\n%d\n", a, 3 * a, 3 * a);
			break;
		case 2:
			scanf("%d%d", &a, &b);
			min = MIN(a, b);
			max = MAX(a, b);
			if (3 * min >= max)
				printf("YES\n%d\n%d\n", 3 * min, 4 * min - max);
			else
				printf("NO\n");
			break;
		case 3:
			scanf("%d%d%d", &a, &b, &c);
			min = MIN(a, MIN(b, c));
			max = MAX(a, MAX(b, c));
			med = a + b + c - min - max;

			if (3 * min == max)
				printf("YES\n%d\n", 4 * min - med);
			else if (3 * min < max)
				printf("NO\n");
			else if ((max + med - min) == min * 3)
				printf("YES\n%d\n", max + med - min);
			else if (3 * (min + med - max) == max)
				printf("YES\n%d\n", min + med - max);
			else
				printf("NO\n");
			break;
		case 4:
			scanf("%d%d%d%d", &a, &b, &c, &d);
			min = MIN(a, MIN(b, MIN(c, d)));
			max = MAX(a, MAX(b, MAX(c, d)));
			printf("%s\n", 3 * min == max && a + b + c + d == 8 * min
					? "YES" : "NO");
			break;
	}
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

double median(int *T)
{
    return ((double)T[1]+(double)T[2])/2;
}

double arithmetic(int *T)
{
    return ((double)T[0]+(double)T[1]+(double)T[2]+(double)T[3])/4;
}

double range(int *T)
{
    return ((double)T[3]-(double)T[0]);
}

int cmp(const void *a, const void *b)
{
    if (*(int*)a > *(int*)b)
        return 1;
    else if (*(int*)a == *(int*)b)
        return 0;
    else
        return -1;
}

int sort(int *T, int k)
{
    int echanger = 1,i;
    while (echanger == 1)
    {
        echanger = 0;
        for (i=0;i<3;++i)
        {
            if (T[i] > T[i+1])
            {
                if (k == i)
                    k = i+1;
                else if (k==(i+1))
                    k = i;
                int aux = T[i];
                T[i] = T[i+1];
                T[i+1] = aux;
                echanger = 1;
            }
        }
    }

    return k;
}

int main()
{
    int n;
    int T[6];
    memset(T,0,sizeof(T));
    scanf("%d", &n);

    //sscanf("3 132 44 126", "%d %d %d %d", &n, &T[0], &T[1], &T[2], &T[3]);

    int i,j,k,l;

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

    if (n == 1)
    {
        for (i = T[0];i <= 1000000;++i)
        {
            T[1] = i;
            for (j = T[1];j <= 1000000;++j)
            {
                T[2] = j;
                T[3] = T[1]+T[2]-T[0];
                double m = median(T);
                double a = arithmetic(T);
                double r = range(T);
                if ((m == a) && (m == r))
                {
                    printf("YES\n");
                    printf("%d\n%d\n%d\n",T[1],T[2],T[3]);
                    return 0;
                }
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 2)
    {
        qsort(T,2,sizeof(int),cmp);
        for (j = T[2];j <= 1000000;++j)
        {
            T[2] = j;
            T[3] = T[1]+T[2]-T[0];

            double m = median(T);
            double a = arithmetic(T);
            double r = range(T);
            if ((m == a) && (m == r))
            {
                printf("YES\n");
                printf("%d\n%d\n",T[2],T[3]);
                return 0;
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 3)
    {
        qsort(T,3,sizeof(int),cmp);
        int k = 3;

        for (i = 1;i <= 1000000;++i)
        {
            T[k] = i;
            k = sort(T,k);
            double m = median(T);
            double a = arithmetic(T);
            double r = range(T);
            if ((m == a) && (m == r))
            {
                printf("YES\n");
                printf("%d\n", T[k]);
                return 0;
            }
        }

        printf("NO\n");

        return 0;
    }
    else if (n == 4)
    {
        qsort(T,4,sizeof(int),cmp);
        double m = median(T);
        double a = arithmetic(T);
        double r = range(T);

        if ((m == a) && (m == r))
            printf("YES\n");
        else
            printf("NO\n");

        return 0;
    }
    else
    {
        T[0] = 1;
        for (i = 1;i <= 1000;++i)
        {
            T[1] = i;
            for (j = T[1];j <= 1000;++j)
            {
                T[2] = j;
                T[3] = T[2]+T[2]-T[0];
                double m = median(T);
                double a = arithmetic(T);
                double r = range(T);
                if ((m == a) && (m == r))
                {
                    printf("YES\n");
                    printf("%d\n%d\n%d\n%d\n",T[0],T[1],T[2],T[3]);
                    return 0;
                }
            }
        }
        printf("NO\n");
        return 0;
    }
}

#include <stdio.h>
#include <stdlib.h>

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

int main()
{
	int A[4];
	int n,i,j;
	int mean,median,range;

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

	qsort(A,n,sizeof(int),cmpfunc);
	if(n==4)
	{
		mean=A[0]+A[1]+A[2]+A[3];

		median=(A[1]+A[2])*2;

		range=(A[3]-A[0])*4;

		if(mean==median && median==range)
			printf("YES\n");
		else
			printf("NO\n");
	}
	else if(n==3)
	{
		int B[4];
		for(i=1;i<=1000000;i++)
		{
			for(j=0;j<3;j++)
				B[j]=A[j];
			B[j]=i;

			qsort(B,4,sizeof(int),cmpfunc);

			median=(B[1]+B[2])*2;
			mean=(B[0]+B[1]+B[2]+B[3]);
			range=(B[3]-B[0])*4;

			if(mean==median && median==range)
			{
				printf("YES\n%d\n",i);
				return 0;
			}
		}
		printf("NO\n");
	}
	else if(n==2)
	{
		int B[4];
		for(i=1;i<=1000000;i++)
		{
			for(j=0;j<2;j++)
				B[j]=A[j];
			int x,y;
			x=i;
			B[j]=i;
			qsort(B,3,sizeof(int),cmpfunc);
			B[3]=B[1]+B[2]-B[0];
			y=B[3];

			qsort(B,4,sizeof(int),cmpfunc);
			median=(B[1]+B[2])*2;
			mean=(B[0]+B[1]+B[2]+B[3]);
			range=(B[3]-B[0])*4;

			if(mean==median && median==range)
			{
				printf("YES\n%d\n%d\n",x,y);
				return 0;
			}
		}
		printf("NO\n");
	}
	else if(n==1 || n==0)
	{
		int a,b,c,d;
		if(n==0)
			b=1;
		else
			b=A[0];
		for(i=1;i<=b;i++)
		{
			a=i;
			for(j=b;j<=1000000;j++)
			{
				c=j;
				median=(b+c)*2;
				mean=a+b+c;
				d=median-mean;
				mean+=d;
				range=(d-a)*4;
				if(range==mean && range==median)
				{
					printf("YES\n");
					printf("%d\n",a);
					if(n==0)
						printf("%d\n",b);
					printf("%d\n",c);
					printf("%d\n",d);
					return 0;
				}
			}
		}
		printf("NO\n");
	}
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
int judge(int s[]);
int cmp(const void *a,const void *b);
int main(void){
	int i,n,boxes[10]={0},temp,state=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&boxes[i]);
	}
	qsort(boxes,n,sizeof(boxes[0]),cmp);
	if(n==1){
        state = 1;
        boxes[1] = 3*boxes[0];
        boxes[2] = boxes[0];
        boxes[3] = boxes[1];
        }
    else if(n == 0){
         boxes[0] = 1;
         boxes[1] = 1;
         boxes[2] = 3;
         boxes[3] = 3;
         state =1;
}
    else if (n==2){
         if(boxes[1] /boxes[0] > 3)
                 state = 0;
         else{
           boxes[2] = 3*boxes[0];
           boxes[3] = 4*boxes[0] - boxes[1];
           state = 1;}
}
    else if (n==3){
         for(i = 1; i<=3*boxes[0];i++){
               boxes[3] = i;
               if(judge(boxes)){
                   state = 1;
                   break;
                   }
                   }
}
    else
         state = judge(boxes);
	if(state){
		printf("YES\n");
		for(i=n;i<4;i++)
			printf("%d\n",boxes[i]);
	}
	else
		printf("NO\n");
	//system("pause");
	return 0;
}
int judge(int s[]){
	int i,temp[4];
    double mean,median,range;
	for(i=0;i<4;i++)
        temp[i] = s[i];
	qsort(temp,4,sizeof(s[0]),cmp);
	mean = (temp[0] + temp[1] + temp[2] +temp[3])/4.0;
	median = (temp[1] + temp[2])/2.0;
	range =(temp[3] - temp[0]);
	return (mean == median) && ( mean == range);
}
int cmp(const void *a,const void *b){
	return *(int *)a - *(int *)b;
}

#include<stdio.h>
int main()
{
	int n,i,j,x,y,z,w,temp,mean,median,range;
	scanf("%d",&n);
	int A[4];
	for(i=0;i<n;i++)
		scanf("%d",&A[i]);
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(A[i]>A[j])
			{
				temp=A[i];
				A[i]=A[j];
				A[j]=temp;
			}
		}
	}
	if(n==0)
		printf("YES\n1\n1\n3\n3\n");
	else if(n==1)
	{
		printf("YES\n%d\n%d\n%d\n",A[0],A[0]*3,A[0]*3);
	}
	else if(n==2)
	{
		x=A[0],y=A[1];
		if(3*x<y)
			printf("NO\n");
		else
			printf("YES\n%d\n%d\n",4*x-y,3*x);
	}
	else if(n==3)
	{
		x=A[0],y=A[1],z=A[2];
		w=3*x;
		mean=(x+y+z+w)/4;
		median=(y+z)/2;
		range=w-x;
		if(mean==median&&median==range)
			printf("YES\n%d\n",w);
		else
		{
			x=A[2]/3,y=A[0],z=A[1],w=A[2];
			mean=(x+y+z+w)/4;
			median=(y+z)/2;
			range=w-x;
			if(mean==median&&median==range)
			printf("YES\n%d\n",x);
			else
			{
				x=A[0],y=A[1],z=A[0]+A[2]-A[1],w=A[2];
				mean=(x+y+z+w)/4;
				median=(y+z)/2;
				range=w-x;
				if(mean==median&&median==range)
					printf("YES\n%d\n",z);
				else
					printf("NO\n");
			}
		}
	}
	else
	{
		x=A[0],y=A[1],z=A[2],w=A[3];
		mean=(x+y+z+w)/4;
		median=(y+z)/2;
		range=w-x;
		if(mean==median&&median==range)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

#include <stdio.h>

int main() {
	int n, a, b, c, d, tmp;

	scanf("%d", &n);
	switch (n) {
		case 0:
			printf("YES\n1\n1\n3\n3\n");
			break;
		case 1:
			scanf("%d", &a);
			printf("YES\n%d\n%d\n%d\n", a, 3 * a, 3 * a);
			break;
		case 2:
			scanf("%d%d", &a, &b);
			if (a > b)
				tmp = a, a = b, b = tmp;
			if (a == b)
				printf("YES\n%d\n%d\n", 3 * a, 3 * a);
			else if (3 * a == b)
				printf("YES\n%d\n%d\n", a, b);
			else
				printf("NO\n");
			break;
		case 3:
			scanf("%d%d%d", &a, &b, &c);
			if (4 * a == b + c)
				printf("YES\n%d\n", 3 * a);
			else
				printf("NO\n");
			break;
		case 4:
			scanf("%d%d%d%d", &a, &b, &c, &d);
			printf("%s\n", d == 3 * a && 4 * a == b * c ? "YES" : "NO");
			break;
	}
	return 0;
}

#include <stdio.h>

#define MIN(A, B) (A < B ? A : B)
#define MAX(A, B) (A > B ? A : B)

int main() {
	int min, max, med, n, a, b, c, d;

	scanf("%d", &n);
	switch (n) {
		case 0:
			printf("YES\n1\n1\n3\n3\n");
			break;
		case 1:
			scanf("%d", &a);
			printf("YES\n%d\n%d\n%d\n", a, 3 * a, 3 * a);
			break;
		case 2:
			scanf("%d%d", &a, &b);
			min = MIN(a, b);
			max = MAX(a, b);
			if (3 * min >= max)
				printf("YES\n%d\n%d\n", 3 * min, 4 * min - max);
			else
				printf("NO\n");
			break;
		case 3:
			scanf("%d%d%d", &a, &b, &c);
			min = MIN(a, MIN(b, c));
			max = MAX(a, MAX(b, c));
			med = a + b + c - min - max;

			if (3 * min == max)
				printf("YES\n%d\n", 4 * min - med);
			else if (3 * min < max)
				printf("NO\n");
			else if ((max + med - min) == min * 3)
				printf("YES\n%d\n", max + med - min);
			else if (3 * (min + med - max) == max)
				printf("YES\n%d\n", min + med - max);
			else
				printf("NO\n");
			break;
		case 4:
			scanf("%d%d%d%d", &a, &b, &c, &d);
			min = MIN(a, MIN(b, MIN(c, d)));
			max = MAX(a, MAX(b, MAX(c, d)));
			printf("%s\n", 3 * min == max && a + b + c + d == 8 * min
					? "YES\n" : "NO\n");
			break;
	}
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int median(int *T)
{
    int sum = T[2]+T[3];
    if (sum%2)
    {
        return -1;
    }
    else
    {
        return (sum)/2;
    }
}

int arithmetic(int *T)
{
    int sum = T[1]+T[2]+T[3]+T[4];
    if (sum%2)
    {
        return -1;
    }
    else
    {
        return (sum)/4;
    }
}

int range(int *T)
{
    return (T[4]-T[1]);
}

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

    int i,j,k,l;
    int T[6];
    for (i = 1;i<=n;++i)
        scanf("%d", &T[i]);

    if (n == 1)
    {
        for (i = 1;i < 500;++i)
        {
            T[2] = i;
            for (j = 1;j < 500;++j)
            {
                T[3] = j;
                for (k = 1;k < 500;++k)
                {
                    T[4] = k;
                    int m = median(T);
                    int a = arithmetic(T);
                    int r = range(T);

                    if ((m == a) && (m == r))
                    {
                        printf("YES\n");
                        printf("%d\n%d\n",T[2],T[3],T[4]);
                        return 0;
                    }
                }
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 2)
    {
        for (j = 1;j < 500;++j)
        {
            T[3] = j;
            for (k = 1;k < 500;++k)
            {
                T[4] = k;
                int m = median(T);
                int a = arithmetic(T);
                int r = range(T);

                if ((m == a) && (m == r))
                {
                    printf("YES\n");
                    printf("%d\n%d\n",T[3],T[4]);
                    return 0;
                }
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 3)
    {
        for (k = 1;k < 500;++k)
        {
            T[4] = k;
            int m = median(T);
            int a = arithmetic(T);
            int r = range(T);

            if ((m == a) && (m == r))
            {
                printf("YES\n");
                printf("%d\n",T[4]);
                return 0;
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 4)
    {
        int m = median(T);
        int a = arithmetic(T);
        int r = range(T);

        if ((m == a) && (m == r))
            printf("YES\n");
        else
            printf("NO\n");
    }
    else
    {
        for (l = 1;l < 500;++l)
        {
            T[1] = l;
            for (i = 1;i < 500;++i)
            {
                T[2] = i;
                for (j = 1;j < 500;++j)
                {
                    T[3] = j;
                    for (k = 1;k < 500;++k)
                    {
                        T[4] = k;
                        int m = median(T);
                        int a = arithmetic(T);
                        int r = range(T);

                        if ((m == a) && (m == r))
                        {
                            printf("YES\n");
                            printf("%d\n%d\n%d\n%d\n",T[1],T[2],T[3],T[4]);
                            return 0;
                        }
                    }
                }
            }
        }

        printf("NO\n");
        return 0;
    }

    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

double median(int *T)
{
    return ((double)T[2]+(double)T[3])/2;
}

double arithmetic(int *T)
{
    return ((double)T[1]+(double)T[2]+(double)T[3]+(double)T[4])/4;
}

double range(int *T)
{
    return ((double)T[4]-(double)T[1]);
}

int min(int *T,int beg)
{
    int i,imin = beg;
    int min = T[beg];
    for (i = beg+1;i<=4;++i)
        if (T[i] < T[beg])
        {
             min = T[i];
             imin = i;
        }

    T[imin] = 1000001;

    return min;
}

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

    int i,j,k,l;
    int T[6];
    memset(T,0,sizeof(T));
    for (i = 1;i<=n;++i)
        scanf("%d", &T[i]);

    if (n == 1)
    {
        for (i = 1;i <= 1000000;++i)
        {
            T[2] = i;
            for (j = 1;j <= 1000000;++j)
            {
                T[3] = j;
                T[4] = T[2]+T[3]-T[1];
                double m = median(T);
                double a = arithmetic(T);
                double r = range(T);
                if ((m == a) && (m == r))
                {
                    if (T[4] > 1000000 || T[4] < 0)
                    {
                        printf("NO\n");
                        return 0;
                    }
                    printf("YES\n");
                    printf("%d\n", min(T,2));
                    printf("%d\n", min(T,2));
                    printf("%d\n", min(T,2));
                    return 0;
                }
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 2)
    {
        for (j = 1;j <= 1000000;++j)
        {
            T[3] = j;
            T[4] = T[2]+T[3]-T[1];

            double m = median(T);
            double a = arithmetic(T);
            double r = range(T);
            if ((m == a) && (m == r))
            {
                if (T[4] > 1000000 || T[4] < 0)
                {
                    printf("NO\n");
                    return 0;
                }
                printf("YES\n");
                if (T[3] >= T[4])
                    printf("%d\n%d\n",T[4],T[3]);
                else
                    printf("%d\n%d\n",T[3],T[4]);
                return 0;
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 3)
    {
        T[4] = T[2]+T[3]-T[1];
        double m = median(T);
        double a = arithmetic(T);
        double r = range(T);

        if ((m == a) && (m == r))
        {
            if (T[4] > 1000000 || T[4] < 0)
            {
                printf("NO\n");
                return 0;
            }
            printf("YES\n");
            printf("%d\n",T[4]);
        }
        else
            printf("NO\n");

        return 0;
    }
    else if (n == 4)
    {
        double m = median(T);
        double a = arithmetic(T);
        double r = range(T);
        if (T[4] > 1000000)
        {
            printf("NO\n");
            return 0;
        }

        if ((m == a) && (m == r))
            printf("YES\n");
        else
            printf("NO\n");

        return 0;
    }
    else
    {
        T[1] = 1;
        for (i = 1;i <= 1000000;++i)
        {
            T[2] = i;
            for (j = 1;j <= 1000000;++j)
            {
                T[3] = j;
                T[4] = T[2]+T[3]-T[1];
                double m = median(T);
                double a = arithmetic(T);
                double r = range(T);
                if ((m == a) && (m == r))
                {
                     if (T[4] > 1000000)
                    {
                        printf("NO\n");
                        return 0;
                    }
                    printf("YES\n");
                    printf("%d\n", min(T,1));
                    printf("%d\n", min(T,1));
                    printf("%d\n", min(T,1));
                    printf("%d\n", min(T,1));
                    return 0;
                }
            }
        }
        printf("NO\n");
        return 0;
    }
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

double median(int *T)
{
    return ((double)T[2]+(double)T[3])/2;
}

double arithmetic(int *T)
{
    return ((double)T[1]+(double)T[2]+(double)T[3]+(double)T[4])/4;
}

double range(int *T)
{
    return ((double)T[4]-(double)T[1]);
}

int cmp(const void *a, const void *b)
{
    if (*(int*)a > *(int*)b)
        return 1;
    else if (*(int*)a == *(int*)b)
        return 0;
    else
        return -1;
}

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

    int i,j,k,l;
    int T[6];
    memset(T,0,sizeof(T));
    for (i = 1;i<=n;++i)
        scanf("%d", &T[i]);

    if (n == 1)
    {
        for (i = T[1];i <= 1000000;++i)
        {
            T[2] = i;
            for (j = T[2];j <= 1000000;++j)
            {
                T[3] = j;
                T[4] = T[2]+T[3]-T[1];
                double m = median(T);
                double a = arithmetic(T);
                double r = range(T);
                if ((m == a) && (m == r))
                {
                    if (T[4] > 1000000 || T[4] < 0)
                    {
                        printf("NO\n");
                        return 0;
                    }
                    printf("YES\n");
                    printf("%d\n%d\n%d\n",T[2],T[3],T[4]);
                    return 0;
                }
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 2)
    {
        qsort(T,2,sizeof(int),cmp);
        for (j = T[2];j <= 1000000;++j)
        {
            T[3] = j;
            T[4] = T[2]+T[3]-T[1];

            double m = median(T);
            double a = arithmetic(T);
            double r = range(T);
            if ((m == a) && (m == r))
            {
                if (T[4] > 1000000 || T[4] < 0)
                {
                    printf("NO\n");
                    return 0;
                }
                printf("YES\n");
                printf("%d\n%d\n",T[3],T[4]);
                return 0;
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 3)
    {
        T[4] = T[2]+T[3]-T[1];
        double m = median(T);
        double a = arithmetic(T);
        double r = range(T);

        if ((m == a) && (m == r))
        {
            if (T[4] > 1000000 || T[4] < 0)
            {
                printf("NO\n");
                return 0;
            }
            printf("YES\n");
            printf("%d\n",T[4]);
        }
        else
            printf("NO\n");

        return 0;
    }
    else if (n == 4)
    {
        double m = median(T);
        double a = arithmetic(T);
        double r = range(T);
        if (T[4] > 1000000)
        {
            printf("NO\n");
            return 0;
        }

        if ((m == a) && (m == r))
            printf("YES\n");
        else
            printf("NO\n");

        return 0;
    }
    else
    {
        T[1] = 1;
        for (i = 1;i <= 1000;++i)
        {
            T[2] = i;
            for (j = 1;j <= 1000;++j)
            {
                T[3] = j;
                T[4] = T[2]+T[3]-T[1];
                double m = median(T);
                double a = arithmetic(T);
                double r = range(T);
                if ((m == a) && (m == r))
                {
                     if (T[4] > 1000000)
                    {
                        printf("NO\n");
                        return 0;
                    }
                    printf("YES\n");
                    printf("%d\n%d\n%d\n%d\n",T[1],T[2],T[3],T[4]);
                    return 0;
                }
            }
        }
        printf("NO\n");
        return 0;
    }
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

double median(int *T)
{
    return ((double)T[2]+(double)T[3])/2;
}

double arithmetic(int *T)
{
    return ((double)T[1]+(double)T[2]+(double)T[3]+(double)T[4])/4;
}

double range(int *T)
{
    return ((double)T[4]-(double)T[1]);
}

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

    int i,j,k,l;
    int T[6];
    for (i = 1;i<=n;++i)
        scanf("%d", &T[i]);

    if (n == 1)
    {
        for (i = 1;i <= 1000000;++i)
        {
            T[2] = i;
            for (j = 1;j <= 1000000;++j)
            {
                T[3] = j;
                T[4] = (int)(((double)T[2]+(double)T[3])/2+(double)T[1]);
                double m = median(T);
                double a = arithmetic(T);
                double r = range(T);
                if ((m == a) && (m == r))
                {
                    printf("YES\n");
                    printf("%d\n%d\n%d\n",T[2],T[3],T[4]);
                    return 0;
                }
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 2)
    {
        for (j = 1;j <= 1000000;++j)
        {
            T[3] = j;
            T[4] = (int)(((double)T[2]+(double)T[3])/2+(double)T[1]);
            if (T[4] > 1000000)
            {
                printf("NO\n");
                return 0;
            }
            double m = median(T);
            double a = arithmetic(T);
            double r = range(T);
            if ((m == a) && (m == r))
            {
                printf("YES\n");
                printf("%d\n%d\n",T[3],T[4]);
                return 0;
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 3)
    {
        T[4] = (int)(((double)T[2]+(double)T[3])/2+(double)T[1]);
        if (T[4] > 1000000)
        {
            printf("NO\n");
            return 0;
        }
        double m = median(T);
        double a = arithmetic(T);
        double r = range(T);

        if ((m == a) && (m == r))
        {
            printf("YES\n");
            printf("%d\n",T[4]);
        }

        else
            printf("NO\n");
        return 0;
    }
    else if (n == 4)
    {
        double m = median(T);
        double a = arithmetic(T);
        double r = range(T);
        if (T[4] > 1000000)
        {
            printf("NO\n");
            return 0;
        }

        if ((m == a) && (m == r))
            printf("YES\n");
        else
            printf("NO\n");
        return 0;
    }
    else
    {
        T[1] = 1;
        for (i = 1;i <= 1000000;++i)
        {
            T[2] = i;
            for (j = 1;j <= 1000000;++j)
            {
                T[3] = j;
                T[4] = (int)(((double)T[2]+(double)T[3])/2+(double)T[1]);
                if (T[4] > 1000000)
                {
                    printf("NO\n");
                    return 0;
                }
                double m = median(T);
                double a = arithmetic(T);
                double r = range(T);
                if ((m == a) && (m == r))
                {
                    printf("YES\n");
                    printf("%d\n%d\n%d\n%d\n",T[1],T[2],T[3],T[4]);
                    return 0;
                }
            }
        }
        printf("NO\n");
        return 0;
    }
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

double median(int *T)
{
    return ((double)T[1]+(double)T[2])/2;
}

double arithmetic(int *T)
{
    return ((double)T[0]+(double)T[1]+(double)T[2]+(double)T[3])/4;
}

double range(int *T)
{
    return ((double)T[3]-(double)T[0]);
}

int cmp(const void *a, const void *b)
{
    if (*(int*)a > *(int*)b)
        return 1;
    else if (*(int*)a == *(int*)b)
        return 0;
    else
        return -1;
}

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

    int i,j,k,l;
    int T[6];
    memset(T,0,sizeof(T));
    for (i=0;i<n;++i)
        scanf("%d", &T[i]);

    if (n == 1)
    {
        for (i = T[0];i <= 1000000;++i)
        {
            T[1] = i;
            for (j = T[1];j <= 1000000;++j)
            {
                T[2] = j;
                T[3] = T[1]+T[2]-T[0];
                double m = median(T);
                double a = arithmetic(T);
                double r = range(T);
                if ((m == a) && (m == r))
                {
                    printf("YES\n");
                    printf("%d\n%d\n%d\n",T[1],T[2],T[3]);
                    return 0;
                }
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 2)
    {
        qsort(T,2,sizeof(int),cmp);
        for (j = T[2];j <= 1000000;++j)
        {
            T[2] = j;
            T[3] = T[1]+T[2]-T[0];

            double m = median(T);
            double a = arithmetic(T);
            double r = range(T);
            if ((m == a) && (m == r))
            {
                printf("YES\n");
                printf("%d\n%d\n",T[2],T[3]);
                return 0;
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 3)
    {
        qsort(T,3,sizeof(int),cmp);
        T[3] = T[1]+T[2]-T[0];
        double m = median(T);
        double a = arithmetic(T);
        double r = range(T);

        if ((m == a) && (m == r))
        {
            printf("YES\n");
            printf("%d\n",T[3]);
        }
        else
            printf("NO\n");

        return 0;
    }
    else if (n == 4)
    {
        double m = median(T);
        double a = arithmetic(T);
        double r = range(T);

        if ((m == a) && (m == r))
            printf("YES\n");
        else
            printf("NO\n");

        return 0;
    }
    else
    {
        T[0] = 1;
        for (i = 1;i <= 1000;++i)
        {
            T[1] = i;
            for (j = T[1];j <= 1000;++j)
            {
                T[2] = j;
                T[3] = T[2]+T[2]-T[0];
                double m = median(T);
                double a = arithmetic(T);
                double r = range(T);
                if ((m == a) && (m == r))
                {
                    printf("YES\n");
                    printf("%d\n%d\n%d\n%d\n",T[0],T[1],T[2],T[3]);
                    return 0;
                }
            }
        }
        printf("NO\n");
        return 0;
    }
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

double median(int *T)
{
    return ((double)T[2]+(double)T[3])/2;
}

double arithmetic(int *T)
{
    return ((double)T[1]+(double)T[2]+(double)T[3]+(double)T[4])/4;
}

double range(int *T)
{
    return ((double)T[4]-(double)T[1]);
}

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

    int i,j,k,l;
    int T[6];
    for (i = 1;i<=n;++i)
        scanf("%d", &T[i]);

    if (n == 1)
    {
        for (i = 1;i < 500;++i)
        {
            T[2] = i;
            for (j = 1;j < 500;++j)
            {
                T[3] = j;
                for (k = 1;k < 500;++k)
                {
                    T[4] = k;
                    double m = median(T);
                    double a = arithmetic(T);
                    double r = range(T);

                    if ((m == a) && (m == r))
                    {
                        printf("YES\n");
                        printf("%d\n%d\n",T[2],T[3],T[4]);
                        return 0;
                    }
                }
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 2)
    {
        for (j = 1;j < 500;++j)
        {
            T[3] = j;
            for (k = 1;k < 500;++k)
            {
                T[4] = k;
                double m = median(T);
                double a = arithmetic(T);
                double r = range(T);

                if ((m == a) && (m == r))
                {
                    printf("YES\n");
                    printf("%d\n%d\n",T[3],T[4]);
                    return 0;
                }
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 3)
    {
        for (k = 1;k < 500;++k)
        {
            T[4] = k;
            double m = median(T);
            double a = arithmetic(T);
            double r = range(T);

            if ((m == a) && (m == r))
            {
                printf("YES\n");
                printf("%d\n",T[4]);
                return 0;
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 4)
    {
        double m = median(T);
        double a = arithmetic(T);
        double r = range(T);

        if ((m == a) && (m == r))
            printf("YES\n");
        else
            printf("NO\n");
    }
    else
    {
        for (l = 1;l < 500;++l)
        {
            T[1] = l;
            for (i = 1;i < 500;++i)
            {
                T[2] = i;
                for (j = 1;j < 500;++j)
                {
                    T[3] = j;
                    for (k = 1;k < 500;++k)
                    {
                        T[4] = k;
                        double m = median(T);
                        double a = arithmetic(T);
                        double r = range(T);

                        if ((m == a) && (m == r))
                        {
                            printf("YES\n");
                            printf("%d\n%d\n%d\n%d\n",T[1],T[2],T[3],T[4]);
                            return 0;
                        }
                    }
                }
            }
        }

        printf("NO\n");
        return 0;
    }

    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

double median(int *T)
{
    return ((double)T[2]+(double)T[3])/2;
}

double arithmetic(int *T)
{
    return ((double)T[1]+(double)T[2]+(double)T[3]+(double)T[4])/4;
}

double range(int *T)
{
    return ((double)T[4]-(double)T[1]);
}

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

    int i,j,k,l;
    int T[6];
    memset(T,0,sizeof(T));
    for (i = 1;i<=n;++i)
        scanf("%d", &T[i]);

    if (n == 1)
    {
        for (i = 1;i <= 1000000;++i)
        {
            T[2] = i;
            for (j = 1;j <= 1000000;++j)
            {
                T[3] = j;
                T[4] = T[2]+T[3]-T[1];
                double m = median(T);
                double a = arithmetic(T);
                double r = range(T);
                if ((m == a) && (m == r))
                {
                    if (T[4] > 1000000 || T[4] < 0)
                    {
                        printf("NO\n");
                        return 0;
                    }
                    printf("YES\n");
                    printf("%d\n%d\n%d\n",T[2],T[3],T[4]);
                    return 0;
                }
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 2)
    {
        for (j = 1;j <= 1000000;++j)
        {
            T[3] = j;
            T[4] = T[2]+T[3]-T[1];

            double m = median(T);
            double a = arithmetic(T);
            double r = range(T);
            if ((m == a) && (m == r))
            {
                if (T[4] > 1000000 || T[4] < 0)
                {
                    printf("NO\n");
                    return 0;
                }
                printf("YES\n");
                printf("%d\n%d\n",T[3],T[4]);
                return 0;
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 3)
    {
        T[4] = T[2]+T[3]-T[1];
        double m = median(T);
        double a = arithmetic(T);
        double r = range(T);

        if ((m == a) && (m == r))
        {
            if (T[4] > 1000000 || T[4] < 0)
            {
                printf("NO\n");
                return 0;
            }
            printf("YES\n");
            printf("%d\n",T[4]);
        }
        else
            printf("NO\n");

        return 0;
    }
    else if (n == 4)
    {
        double m = median(T);
        double a = arithmetic(T);
        double r = range(T);
        if (T[4] > 1000000)
        {
            printf("NO\n");
            return 0;
        }

        if ((m == a) && (m == r))
            printf("YES\n");
        else
            printf("NO\n");

        return 0;
    }
    else
    {
        T[1] = 1;
        for (i = 1;i <= 1000000;++i)
        {
            T[2] = i;
            for (j = 1;j <= 1000000;++j)
            {
                T[3] = j;
                T[4] = T[2]+T[3]-T[1];
                double m = median(T);
                double a = arithmetic(T);
                double r = range(T);
                if ((m == a) && (m == r))
                {
                     if (T[4] > 1000000)
                    {
                        printf("NO\n");
                        return 0;
                    }
                    printf("YES\n");
                    printf("%d\n%d\n%d\n%d\n",T[1],T[2],T[3],T[4]);
                    return 0;
                }
            }
        }
        printf("NO\n");
        return 0;
    }
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

double median(int *T)
{
    return ((double)T[2]+(double)T[3])/2;
}

double arithmetic(int *T)
{
    return ((double)T[1]+(double)T[2]+(double)T[3]+(double)T[4])/4;
}

double range(int *T)
{
    return ((double)T[4]-(double)T[1]);
}

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

    int i,j,k,l;
    int T[6];
    for (i = 1;i<=n;++i)
        scanf("%d", &T[i]);

    if (n == 1)
    {
        for (i = 1;i <= 1000000;++i)
        {
            T[2] = i;
            for (j = 1;j <= 1000000;++j)
            {
                T[3] = j;
                T[4] = (int)(((double)T[2]+(double)T[3])/2+(double)T[1]);
                double m = median(T);
                double a = arithmetic(T);
                double r = range(T);
                if ((m == a) && (m == r))
                {
                    printf("YES\n");
                    printf("%d\n%d\n",T[3],T[4]);
                    return 0;
                }
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 2)
    {
        for (j = 1;j <= 1000000;++j)
        {
            T[3] = j;
            T[4] = (int)(((double)T[2]+(double)T[3])/2+(double)T[1]);
            if (T[4] > 1000000)
            {
                printf("NO\n");
                return 0;
            }
            double m = median(T);
            double a = arithmetic(T);
            double r = range(T);
            if ((m == a) && (m == r))
            {
                printf("YES\n");
                printf("%d\n%d\n",T[3],T[4]);
                return 0;
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 3)
    {
        T[4] = (int)(((double)T[2]+(double)T[3])/2+(double)T[1]);
        if (T[4] > 1000000)
        {
            printf("NO\n");
            return 0;
        }
        double m = median(T);
        double a = arithmetic(T);
        double r = range(T);

        if ((m == a) && (m == r))
            printf("YES\n");
        else
            printf("NO\n");
        return 0;
    }
    else if (n == 4)
    {
        double m = median(T);
        double a = arithmetic(T);
        double r = range(T);
        if (T[4] > 1000000)
        {
            printf("NO\n");
            return 0;
        }

        if ((m == a) && (m == r))
            printf("YES\n");
        else
            printf("NO\n");
        return 0;
    }
    else
    {
        T[1] = 1;
        for (i = 1;i <= 1000000;++i)
        {
            T[2] = i;
            for (j = 1;j <= 1000000;++j)
            {
                T[3] = j;
                T[4] = (int)(((double)T[2]+(double)T[3])/2+(double)T[1]);
                if (T[4] > 1000000)
                {
                    printf("NO\n");
                    return 0;
                }
                double m = median(T);
                double a = arithmetic(T);
                double r = range(T);
                if ((m == a) && (m == r))
                {
                    printf("YES\n");
                    printf("%d\n%d\n",T[3],T[4]);
                    return 0;
                }
            }
        }
        printf("NO\n");
        return 0;
    }
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

double median(int *T)
{
    return ((double)T[1]+(double)T[2])/2;
}

double arithmetic(int *T)
{
    return ((double)T[0]+(double)T[1]+(double)T[2]+(double)T[3])/4;
}

double range(int *T)
{
    return ((double)T[3]-(double)T[0]);
}

int cmp(const void *a, const void *b)
{
    if (*(int*)a > *(int*)b)
        return 1;
    else if (*(int*)a == *(int*)b)
        return 0;
    else
        return -1;
}

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

    int i,j,k,l;
    int T[6];
    memset(T,0,sizeof(T));
    for (i=0;i<n;++i)
        scanf("%d", &T[i]);

    if (n == 1)
    {
        for (i = T[0];i <= 1000000;++i)
        {
            T[1] = i;
            for (j = T[1];j <= 1000000;++j)
            {
                T[2] = j;
                T[3] = T[1]+T[2]-T[0];
                double m = median(T);
                double a = arithmetic(T);
                double r = range(T);
                if ((m == a) && (m == r))
                {
                    printf("YES\n");
                    printf("%d\n%d\n%d\n",T[1],T[2],T[3]);
                    return 0;
                }
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 2)
    {
        qsort(T,2,sizeof(int),cmp);
        for (j = T[2];j <= 1000000;++j)
        {
            T[2] = j;
            T[3] = T[1]+T[2]-T[0];

            double m = median(T);
            double a = arithmetic(T);
            double r = range(T);
            if ((m == a) && (m == r))
            {
                printf("YES\n");
                printf("%d\n%d\n",T[2],T[3]);
                return 0;
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 3)
    {
        T[3] = T[1]+T[2]-T[0];
        double m = median(T);
        double a = arithmetic(T);
        double r = range(T);

        if ((m == a) && (m == r))
        {
            printf("YES\n");
            printf("%d\n",T[3]);
        }
        else
            printf("NO\n");

        return 0;
    }
    else if (n == 4)
    {
        double m = median(T);
        double a = arithmetic(T);
        double r = range(T);

        if ((m == a) && (m == r))
            printf("YES\n");
        else
            printf("NO\n");

        return 0;
    }
    else
    {
        T[0] = 1;
        for (i = 1;i <= 1000;++i)
        {
            T[1] = i;
            for (j = T[1];j <= 1000;++j)
            {
                T[2] = j;
                T[3] = T[2]+T[2]-T[0];
                double m = median(T);
                double a = arithmetic(T);
                double r = range(T);
                if ((m == a) && (m == r))
                {
                    printf("YES\n");
                    printf("%d\n%d\n%d\n%d\n",T[0],T[1],T[2],T[3]);
                    return 0;
                }
            }
        }
        printf("NO\n");
        return 0;
    }
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

double median(int *T)
{
    return ((double)T[1]+(double)T[2])/2;
}

double arithmetic(int *T)
{
    return ((double)T[0]+(double)T[1]+(double)T[2]+(double)T[3])/4;
}

double range(int *T)
{
    return ((double)T[3]-(double)T[0]);
}

int cmp(const void *a, const void *b)
{
    if (*(int*)a > *(int*)b)
        return 1;
    else if (*(int*)a == *(int*)b)
        return 0;
    else
        return -1;
}

int sort(int *T, int k)
{
    int echanger = 1,i;
    while (echanger == 1)
    {
        echanger = 0;
        for (i=0;i<3;++i)
        {
            if (T[i] > T[i+1])
            {
                if (k == i)
                    k = i+1;
                else if (k==(i+1))
                    k = i;
                int aux = T[i];
                T[i] = T[i+1];
                T[i+1] = aux;
                echanger = 1;
            }
        }
    }

    return k;
}

int main()
{
    int n;
    int T[6];
    memset(T,0,sizeof(T));
    scanf("%d", &n);

    //sscanf("3 132 44 126", "%d %d %d %d", &n, &T[0], &T[1], &T[2], &T[3]);

    int i,j,k,l;

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

    if (n == 1)
    {
        for (i = T[0];i <= 1000000;++i)
        {
            T[1] = i;
            for (j = T[1];j <= 1000000;++j)
            {
                T[2] = j;
                T[3] = T[1]+T[2]-T[0];
                double m = median(T);
                double a = arithmetic(T);
                double r = range(T);
                if ((m == a) && (m == r))
                {
                    printf("YES\n");
                    printf("%d\n%d\n%d\n",T[1],T[2],T[3]);
                    return 0;
                }
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 2)
    {
        qsort(T,2,sizeof(int),cmp);
        for (j = T[2];j <= 1000000;++j)
        {
            T[2] = j;
            T[3] = T[1]+T[2]-T[0];

            double m = median(T);
            double a = arithmetic(T);
            double r = range(T);
            if ((m == a) && (m == r))
            {
                printf("YES\n");
                printf("%d\n%d\n",T[2],T[3]);
                return 0;
            }
        }
        printf("NO\n");
        return 0;
    }
    else if (n == 3)
    {
        qsort(T,3,sizeof(int),cmp);
        int k = 3;

        for (i = 1;i <= 1000000;++i)
        {
            T[k] = i;
            k = sort(T,k);
            double m = median(T);
            double a = arithmetic(T);
            double r = range(T);
            if ((m == a) && (m == r))
            {
                printf("YES\n");
                printf("%d\n", T[k]);
                return 0;
            }
        }

        printf("NO\n");

        return 0;
    }
    else if (n == 4)
    {
        double m = median(T);
        double a = arithmetic(T);
        double r = range(T);

        if ((m == a) && (m == r))
            printf("YES\n");
        else
            printf("NO\n");

        return 0;
    }
    else
    {
        T[0] = 1;
        for (i = 1;i <= 1000;++i)
        {
            T[1] = i;
            for (j = T[1];j <= 1000;++j)
            {
                T[2] = j;
                T[3] = T[2]+T[2]-T[0];
                double m = median(T);
                double a = arithmetic(T);
                double r = range(T);
                if ((m == a) && (m == r))
                {
                    printf("YES\n");
                    printf("%d\n%d\n%d\n%d\n",T[0],T[1],T[2],T[3]);
                    return 0;
                }
            }
        }
        printf("NO\n");
        return 0;
    }
}

#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#define Y "YES"
#define N "NO"
int main(void)
{
    int n;
    long long x1, x2, x3, x4;
    bool find = false;
    scanf("%d", &n);
    if (n == 0)
        printf("%s\n%I64d\n%I64d\n%I64d\n%I64d\n", Y,1,1,3,3);
    else if (n == 1)
    {
        scanf("%I64d", &x1);
        x4 = 3*x1;
        for (x2 = x1; x2 <= x4&&!find; x2++)
            {
                for (x3 = x2; x3 <= x4&&!find; x3++)
                    if ((x2 + x3) == 4 * x1)
                    {
                        find = true;
                        break;
                    }
                if (find)
                  break;
            }
        if (find)
            printf("%s\n%I64d\n%I64d\n%I64d\n", Y, x2, x3, x4);
        else
            printf("%s\n", N);

    }
    else if (n == 2)
    {
        scanf("%I64d%I64d", &x1, &x2);
        x4 = 3 * x1;
                for (x3 = x2; x3 <= x4&&!find;x3++)
                    if (x3 == (4 * x1 - x2) && x3 >= x2)
                        {
                            find = true;
                            break;
                        }
        if (find)
            printf("%s\n%I64d\n%I64d\n", Y, x3, x4);
        else
            printf("%s\n", N);
    }
    else if (n == 3)
    {
        scanf("%I64d%I64d%I64d", &x1, &x2, &x3);
        x4 = 3* x1;
            if (x4 >= x3 && (x2 + x3) == 4 * x1)
                find = true;
            else
                find = false;
        if (find)
            printf("%s\n%I64d\n", Y, x4);
        else
            printf("%s\n", N);

    }
    else
    {
        scanf("%I64d%I64d%I64d%I64d", &x1, &x2, &x3, &x4);
            if (x4 = 3 * x1 && (x2 + x3) == 4 * x1)
                find = true;
            else
                find = false;
        if (find)
            printf("%s\n", Y);
        else
            printf("%s\n", N);
    }

    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#define Y "YES"
#define N "NO"
int main(void)
{
    int n;
    long long x1, x2, x3, x4;
    bool find = false;
    scanf("%d", &n);
    if (n == 0)
        printf("%s\n%d\n%d\n%d\n%d\n", Y,1,1,3,3);
    else if (n == 1)
    {
        scanf("%lld", &x1);
        x4 = 3*x1;
        for (x2 = x1; x2 <= x4&&!find; x2++)
            {
                for (x3 = x2; x3 <= x4&&!find; x3++)
                    if ((x2 + x3) == 4 * x1)
                    {
                        find = true;
                        break;
                    }
                if (find)
                  break;
            }
        if (find)
            printf("%s\n%lld\n%lld\n%lld\n", Y, x2, x3, x4);
        else
            printf("%s\n", N);

    }
    else if (n == 2)
    {
        scanf("%lld%lld", &x1, &x2);
        x4 = 3 * x1;
                for (x3 = x2; x3 <= x4&&!find;x3++)
                    if (x3 == (4 * x1 - x2) && x3 >= x2)
                        {
                            find = true;
                            break;
                        }
        if (find)
            printf("%s\n%lld\n%lld\n", Y, x3, x4);
        else
            printf("%s\n", N);
    }
    else if (n == 3)
    {
        scanf("%lld%lld%lld", &x1, &x2, &x3);
        x4 = 3* x1;
            if (x4 >= x3 && (x2 + x3) == 4 * x1)
                find = true;
            else
                find = false;
        if (find)
            printf("%s\n%lld\n", Y, x4);
        else
            printf("%s\n", N);

    }
    else
    {
        scanf("%lld%lld%lld%lld", &x1, &x2, &x3, &x4);
            if (x4 = 3 * x1 && (x2 + x3) == 4 * x1)
                find = true;
            else
                find = false;
        if (find)
            printf("%s\n", Y);
        else
            printf("%s\n", N);
    }

    return 0;
}

#include <stdio.h>
#include <stdlib.h>

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

int main()
{
	int A[4];
	int n,i,j;
	int mean,median,range;

	scanf("%d",&n);
	if(n==0)
		return 0;
	for(i=0;i<n;i++)
		scanf("%d",&A[i]);

	qsort(A,n,sizeof(int),cmpfunc);
	if(n==4)
	{
		mean=A[0]+A[1]+A[2]+A[3];

		median=(A[1]+A[2])*2;

		range=(A[3]-A[0])*4;

		if(mean==median && median==range)
			printf("YES\n");
		else
			printf("NO\n");
	}
	else if(n==3)
	{
		int B[4];
		for(i=1;i<=1000000;i++)
		{
			for(j=0;j<3;j++)
				B[j]=A[j];
			B[j]=i;

			qsort(B,4,sizeof(int),cmpfunc);

			median=(B[1]+B[2])*2;
			mean=(B[0]+B[1]+B[2]+B[3]);
			range=(B[3]-B[0])*4;

			if(mean==median && median==range)
			{
				printf("YES\n%d\n",i);
				return 0;
			}
		}
		printf("NO\n");
	}
	else if(n==2)
	{
		int B[4];
		for(i=1;i<=1000000;i++)
		{
			for(j=0;j<2;j++)
				B[j]=A[j];
			int x,y;
			x=i;
			B[j]=i;
			qsort(B,3,sizeof(int),cmpfunc);
			B[3]=B[1]+B[2]-B[0];
			y=B[3];

			qsort(B,4,sizeof(int),cmpfunc);
			median=(B[1]+B[2])*2;
			mean=(B[0]+B[1]+B[2]+B[3]);
			range=(B[3]-B[0])*4;

			if(mean==median && median==range)
			{
				printf("YES\n%d\n%d\n",x,y);
				return 0;
			}
		}
		printf("NO\n");
	}
	else if(n==1)
	{
		int a,b,c,d;
		b=A[0];
		for(i=1;i<=b;i++)
		{
			a=i;
			for(j=b;j<=1000000;j++)
			{
				c=j;
				median=(b+c)*2;
				mean=a+b+c;
				d=median-mean;
				mean+=d;
				range=(d-a)*4;
				if(range==mean && range==median)
				{
					printf("YES\n");
					printf("%d\n",a);
					printf("%d\n",c);
					printf("%d\n",d);
					return 0;
				}
			}
		}
		printf("NO\n");
	}
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

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

int main()
{
	int A[4];
	int n,i,j;
	int mean,median,range;

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

	qsort(A,n,sizeof(int),cmpfunc);
	if(n==4)
	{
		mean=A[0]+A[1]+A[2]+A[3];

		median=(A[1]+A[2])*2;

		range=(A[3]-A[0])*4;

		if(mean==median && median==range)
			printf("YES\n");
		else
			printf("NO\n");
	}
	else if(n==3)
	{
		int B[4];
		for(i=1;i<=1000000;i++)
		{
			for(j=0;j<3;j++)
				B[j]=A[j];
			B[j]=i;

			qsort(B,4,sizeof(int),cmpfunc);

			median=(B[1]+B[2])*2;
			mean=(B[0]+B[1]+B[2]+B[3]);
			range=(B[3]-B[0])*4;

			if(mean==median && median==range)
			{
				printf("YES\n%d\n",i);
				return 0;
			}
		}
		printf("NO\n");
	}
	else if(n==2)
	{
		int B[4];
		for(i=1;i<=1000000;i++)
		{
			for(j=0;j<2;j++)
				B[j]=A[j];
			int x,y;
			x=i;
			B[j]=i;
			qsort(B,3,sizeof(int),cmpfunc);
			B[3]=B[1]+B[2]-B[0];
			y=B[3];

			qsort(B,4,sizeof(int),cmpfunc);
			median=(B[1]+B[2])*2;
			mean=(B[0]+B[1]+B[2]+B[3]);
			range=(B[3]-B[0])*4;

			if(mean==median && median==range)
			{
				printf("YES\n%d\n%d\n",x,y);
				return 0;
			}
		}
		printf("NO\n");
	}
	else if(n==1)
	{
		int a,b,c,d;
		a=A[0];
		for(i=a;i<=1000000;i++)
		{
			d=i;
			range=(d-a)*4;
			for(j=a;j<=d;j++)
			{
				b=j;
				c=range-(a+b+d);
				if(c>=b && c<= d)
				{
					median=(b+c)*2;
					if(median==range)
					{
						printf("YES\n");
						printf("%d\n%d\n%d\n",b,c,d);
					}
				}
			}
		}
		printf("NO\n");
	}
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

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

int main()
{
	int A[4];
	int n,i,j;
	int mean,median,range;

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

	qsort(A,n,sizeof(int),cmpfunc);
	if(n==4)
	{
		mean=A[0]+A[1]+A[2]+A[3];

		median=(A[1]+A[2])*2;

		range=(A[3]-A[0])*4;

		if(mean==median && median==range)
			printf("YES\n");
		else
			printf("NO\n");
	}
	else if(n==3)
	{
		int B[4];
		for(i=1;i<=1000000;i++)
		{
			for(j=0;j<3;j++)
				B[j]=A[j];
			B[j]=i;

			qsort(B,4,sizeof(int),cmpfunc);

			median=(B[1]+B[2])*2;
			mean=(B[0]+B[1]+B[2]+B[3]);
			range=(B[3]-B[0])*4;

			if(mean==median && median==range)
			{
				printf("YES\n%d\n",i);
				return 0;
			}
		}
		printf("NO\n");
	}
	else if(n==2)
	{
		int B[4];
		for(i=1;i<=1000000;i++)
		{
			for(j=0;j<2;j++)
				B[j]=A[j];
			int x,y;
			x=i;
			B[j]=i;
			qsort(B,3,sizeof(int),cmpfunc);
			B[3]=B[1]+B[2]-B[0];
			y=B[3];

			qsort(B,4,sizeof(int),cmpfunc);
			median=(B[1]+B[2])*2;
			mean=(B[0]+B[1]+B[2]+B[3]);
			range=(B[3]-B[0])*4;

			if(mean==median && median==range)
			{
				printf("YES\n%d\n%d\n",x,y);
				return 0;
			}
		}
		printf("NO\n");
	}
	else if(n==1)
	{
		int a,b,c,d;
		b=A[0];
		for(i=1;i<=b;i++)
		{
			a=i;
			for(j=b;j<=1000000;j++)
			{
				c=j;
				median=(b+c)*2;
				mean=a+b+c;
				d=median-mean;
				mean+=d;
				range=(d-a)*4;
				if(range==mean && range==median)
				{
					printf("YES\n");
					printf("%d\n",a);
					printf("%d\n",c);
					printf("%d\n",d);
					return 0;
				}
			}
		}
		printf("NO\n");
	}
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
int judge(int s[]);
int cmp(const void *a,const void *b);
int main(void){
	int i,n,boxes[10]={0},temp,state=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&boxes[i]);
	}
	qsort(boxes,n,sizeof(boxes[0]),cmp);
	if(n==1){
        state = 1;
        boxes[1] = 3*boxes[0];
        boxes[2] = boxes[0];
        boxes[3] = boxes[1];
        }
    else if (n==2){
         if(boxes[1] /boxes[0] > 3)
                 state = 0;
         else{
           boxes[2] = 3*boxes[0];
           boxes[3] = 4*boxes[0] - boxes[1];
           state = 1;}
}
    else if (n==3){
         for(i = 1; i<=3*boxes[0];i++){
               boxes[3] = i;
               if(judge(boxes)){
                   state = 1;
                   break;
                   }
                   }
}
    else
         state = judge(boxes);
	if(state){
		printf("YES\n");
		for(i=n;i<4;i++)
			printf("%d\n",boxes[i]);
	}
	else
		printf("NO\n");
	//system("pause");
	return 0;
}
int judge(int s[]){
	int i,temp[4];
    double mean,median,range;
	for(i=0;i<4;i++)
        temp[i] = s[i];
	qsort(temp,4,sizeof(s[0]),cmp);
	mean = (temp[0] + temp[1] + temp[2] +temp[3])/4.0;
	median = (temp[1] + temp[2])/2.0;
	range =(temp[3] - temp[0]);
	return (mean == median) && ( mean == range);
}
int cmp(const void *a,const void *b){
	return *(int *)a - *(int *)b;
}

#include<stdio.h>
int main()
{
	int n,i,j,x,y,z,w,temp,mean,median,range;
	scanf("%d",&n);
	int A[4];
	for(i=0;i<n;i++)
		scanf("%d",&A[i]);
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(A[i]>A[j])
			{
				temp=A[i];
				A[i]=A[j];
				A[j]=temp;
			}
		}
	}
	if(n==0)
		printf("YES\n1\n1\n3\n3\n");
	else if(n==1)
	{
		printf("YES\n%d\n%d\n%d\n",A[0],A[0]*3,A[0]*3);
	}
	else if(n==2)
	{
		x=A[0],y=A[1];
		if(3*x<y)
			printf("NO\n");
		else
			printf("YES\n%d\n%d\n",4*x-y,3*x);
	}
	else if(n==3)
	{
		x=A[0],y=A[1],z=A[2];
		w=3*x;
		mean=(x+y+z+w)/4;
		median=(y+z)/2;
		range=w-x;
		if(mean==median&&median==range)
			printf("YES\n%d\n",3*x);
		else
			printf("NO\n");
	}
	else
	{
		x=A[0],y=A[1],z=A[2],w=A[3];
		mean=(x+y+z+w)/4;
		median=(y+z)/2;
		range=w-x;
		if(mean==median&&median==range)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

#include<stdio.h>
int main()
{
	int n,i,j,x,y,z,w,temp,mean,median,range;
	scanf("%d",&n);
	int A[4];
	for(i=0;i<n;i++)
		scanf("%d",&A[i]);
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(A[i]>A[j])
			{
				temp=A[i];
				A[i]=A[j];
				A[j]=temp;
			}
		}
	}
	if(n==0)
		printf("YES\n1\n1\n3\n3\n");
	else if(n==1)
	{
		printf("YES\n%d\n%d\n%d\n",A[0],A[0]*3,A[0]*3);
	}
	else if(n==2)
	{
		x=A[0],y=A[1];
		if(3*x<y)
			printf("NO\n");
		else
			printf("YES\n%d\n%d\n",4*x-y,3*x);
	}
	else if(n==3)
	{
		x=A[0],y=A[1],z=A[3];
		if(3*x>z)
			printf("NO\n");
		else
			printf("YES\n%d\n",3*x);
	}
	else
	{
		x=A[0],y=A[1],z=A[2],w=A[3];
		mean=(x+y+z+w)/4;
		median=(y+z)/2;
		range=w-x;
		if(mean==median&&median==range)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

#include<stdio.h>
int main()
{
	int n,i,j,x,y,z,w,temp,mean,median,range;
	scanf("%d",&n);
	int A[4];
	for(i=0;i<n;i++)
		scanf("%d",&A[i]);
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(A[i]>A[j])
			{
				temp=A[i];
				A[i]=A[j];
				A[j]=temp;
			}
		}
	}
	if(n==0)
		printf("YES\n1\n1\n3\n3\n");
	else if(n==1)
	{
		printf("YES\n%d\n%d\n%d\n",A[0],A[0]*3,A[0]*3);
	}
	else if(n==2)
	{
		x=A[0],y=A[1];
		if(3*x<y)
			printf("NO\n");
		else
			printf("YES\n%d\n%d\n",4*x-y,3*x);
	}
	else if(n==3)
	{
		x=A[0],y=A[1],z=A[2];
		if(3*x<z)
			printf("NO\n");
		else
			printf("YES\n%d\n",3*x);
	}
	else
	{
		x=A[0],y=A[1],z=A[2],w=A[3];
		mean=(x+y+z+w)/4;
		median=(y+z)/2;
		range=w-x;
		if(mean==median&&median==range)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

#include<stdio.h>
int main()
{
	int n,i,j,x,y,z,w,temp,mean,median,range;
	scanf("%d",&n);
	int A[4];
	for(i=0;i<n;i++)
		scanf("%d",&A[i]);
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(A[i]>A[j])
			{
				temp=A[i];
				A[i]=A[j];
				A[j]=temp;
			}
		}
	}
	if(n==0)
		printf("YES\n1\n1\n3\n3\n");
	else if(n==1)
	{
		printf("YES\n%d\n%d\n%d\n",A[0],A[0]*3,A[0]*3);
	}
	else if(n==2)
	{
		x=A[0],y=A[1];
		if(3*x<y)
			printf("NO\n");
		else
			printf("YES\n%d\n%d\n",4*x-y,3*x);
	}
	else if(n==3)
	{
		x=A[0],y=A[1],z=A[3];
		if(3*x<z)
			printf("NO\n");
		else
			printf("YES\n%d\n",3*x);
	}
	else
	{
		x=A[0],y=A[1],z=A[2],w=A[3];
		mean=(x+y+z+w)/4;
		median=(y+z)/2;
		range=w-x;
		if(mean==median&&median==range)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}


Your task is to calculate the number of arrays such that:  each array contains $$$n$$$ elements;  each element is an integer from $$$1$$$ to $$$m$$$;  for each array, there is exactly one pair of equal elements;  for each array $$$a$$$, there exists an index $$$i$$$ such that the array is strictly ascending before the $$$i$$$-th element and strictly descending after it (formally, it means that $$$a_j < a_{j + 1}$$$, if $$$j < i$$$, and $$$a_j > a_{j + 1}$$$, if $$$j \ge i$$$).

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le m \le 2 \cdot 10^5$$$).

Print one integer — the number of arrays that meet all of the aforementioned conditions, taken modulo $$$998244353$$$.

#include<stdio.h>
long long int fact[200005];
long long int modpow(long long int a, long long int n, long long int p)
{
	if (n < 0)
		return 0;
	long long int res = 1;
	while (n > 0)
	{
		if (n % 2 > 0)
			res = res * a % p;
		a = a * a % p;
		n /= 2;
	}
	return res;
}
long long int comb(long long int n, long long int r, long long int p)
{
	if (n < 0 || r < 0 || n < r)
		return 0;
	long long int res = fact[n];
	res = res * modpow(fact[r], p - 2, p) % p;
	res = res * modpow(fact[n - r], p - 2, p) % p;
	return res;
}
int main()
{
	long long int n, m;
	scanf("%lld %lld", &n, &m);
	long long int p = 998244353;
	long long int ans = 0;
	long long int i;
	fact[0] = 1;
	for (i = 1; i <= m; i++)
		fact[i] = fact[i - 1] * i % p;
	for (i = 1; i < m; i++)
		ans = (ans + comb(m - 1, n - 2, p) - comb(i - 1, n - 2, p) + p) % p;
	ans = ans * modpow(2, n - 3, p) % p;
	printf("%lld\n", ans);
	return 0;
}

#include <stdio.h>
#include<math.h>
#include<stdlib.h>
long long int power(long long int x, long long int y, long long int p)
{
    long long int res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
long long int modInverse(long long int n,long long int p)
{
    return power(n, p-2, p);
}
long long int nCrModPFermat(long long int n,long long int r,long long int p)
{
   // Base case
   if (r==0)
      return 1;

    // Fill factorial array so that we
    // can find all factorial of r, n
    // and n-r
    long long int fac[n+1];
    fac[0] = 1;
    for (int i=1 ; i<=n; i++)
        fac[i] = fac[i-1]*i%p;

    return (fac[n]* modInverse(fac[r], p) % p *
            modInverse(fac[n-r], p) % p) % p;
}
int main()
{
    long long int n, m;
    scanf("%lld %lld", &n, &m);
    if(n==2)
    {
        printf("0");
        return 0;
    }
    long long int p=998244353;
   long long int ans= nCrModPFermat(m, n-1, p);
   for(int i=0;i<n-3;i++)
   ans=ans*2%p;
   ans=ans*(n-2)%p;
   printf("%lld",ans);
}

/*  AUTHOR: AKASH JAIN
*   EMAIL:  akash19jain@gmail.com
*   ID:     akash19jain
*   DATE:   10-03-2020 11:55:10
*/

// #include<algorithm>
// #include <bits/stdc++.h>
// using namespace std;

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
#define SC1(x)          scanf("%lld",&x)
#define SC2(x,y)        scanf("%lld%lld",&x,&y)
#define SC3(x,y,z)      scanf("%lld%lld%lld",&x,&y,&z)
#define SCS(x)          scanf("\n%s", x)
#define SCA(a,n)        for(long long i=0;i<n;i++)    scanf("%lld",&a[i]);
#define PF1(x)          printf("%lld\n",x)
#define PF2(x,y)        printf("%lld %lld\n",x,y)
#define PF3(x,y,z)      printf("%lld %lld %lld\n",x,y,z)
#define PFA(a,n)        for(long long i=0;i<n;i++)    printf("%lld ",a[i]); printf("\n");
#define PFN             printf("\n")
#define PFS(x)          printf("%s\n",x)
#define REP(i,n)        for(long long i=0;i<(n);++i)
#define FOR(i,a,b)      for(long long i=(a);i<=(b);++i)
#define FORD(i,a,b)     for(long long i=(a);i>=(b);--i)
#define WHILE(n)        while(n--)
#define MEM(a, b)       memset(a, (b), sizeof(a))
#define ITOC(c)         ((char)(((ll)'0')+c))
#define MID(s,e)        (s+(e-s)/2)
#define SZ(a)           strlen(a)
#define PI              3.1415926535897932384626433832795
#define DEB(x)          printf("The value of \"%s\" is: %d\n",#x,x)
#define CASES           ll t;SC1(t);while(t--)
#define ABS(a)          ((a>0)?a:-(a))
#define SWAP(a,b)       ll z=a;a=b;b=z
#define SWAPC(a,b)      char z=a;a=b;b=z
#define FLSH            fflush(stdout)
typedef long long ll;
typedef unsigned long long ull;
const ll INF = 1<<29;
const ll MOD = 1000000007;
const ll FMOD = 998244353;
const ll MAX = 10000000005;
const ll MIN = -10000000005;
#define FILEIO(name) \  freopen(name".in", "r", stdin); \   freopen(name".out", "w", stdout);
int cmp(const void * a,const void * b);
long long maxv(long long a,long long b);
long long minv(long long a,long long b);
long long gcd(long long u,long long v);
long long digits(long long n);
bool ispoweroftwo(long long n);
bool isvowel(char x);
ll chartoint(char ch);
ll CEIL(ll x,ll y);
ll FLOOR(ll x,ll y);

//Final answer : mC(n-1) * (n-2)C1 * 2^(n-3);
ll inv(ll a,ll p)
{
    ll b=p-2,ans=1;
    for(;b > 0;a = a * a % p,b >>= 1)
        if(b & 1)
            ans = ans * a % p;
    return ans;
}
ll ncr(ll n,ll m,ll p)
{
    if(m > n)
        return 0;
    ll up=1,down=1;
    for(int i=n-m+1;i<n+1;i++)
        up*=i,up%=p;
    for(int i=1;i<m+1;i++)
        down*=i,down%=p;
    return up*inv(down,p)%p;
}
int main()
{
    ll n,m;
    SC2(n,m);
    ll ans=1;
    FOR(i,1,n-3)
        ans=ans*2%FMOD;

    ans=(ans*(n-2))%FMOD;

    ans=ans*ncr(m,n-1,FMOD)%FMOD;

    PF1(ans);

    return 0;
}

//qsort(arr,n,sizeof(arr[0]),cmp);
int cmp (const void * a, const void * b)
{
    if( *(ll*)a - *(ll*)b < 0 ) return -1;
    if( *(ll*)a - *(ll*)b > 0 ) return 1;
        return 0;
}
long long maxv(long long a,long long b)
{
    if(a>b) return a;
        return b;
}
long long minv(long long a,long long b)
{
    if(a<b) return a;
        return b;
}
long long gcd(long long u,long long v)
{
    if (v == 0) return u;
       return gcd(v, u%v);
}
long long digits(long long n)    //to calculate no of digits in a number
{
    return floor(log10(n))+1;
}
bool ispoweroftwo(long long x)
{
    return x && (!(x&(x-1)));
}
bool isvowel(char x)
{
    return(x=='a' || x== 'e' ||x=='i' || x== 'o' || x=='u' );
}
ll chartoint(char ch)
{
    if(ch>='A' && ch<='Z') return(ch-'A');
    else if(ch>='0' && ch<='9') return (ch-'0');
    else if(ch>='a' && ch<='z') return (ch-'a');
    else return 0;
}
ll CEIL(ll x,ll y)
{
    if(x%y==0) return(x/y);
    else return(x/y +1);
}

ll FLOOR(ll x,ll y)
{
    if(x%y==0) return(x/y);
    else return(x/y -1);
}

#include <stdio.h>
#define MOD 998244353

__int64 Pow(__int64 a, __int64 b)
{
    if (b == 0) return 1;
	if (b % 2 > 0) return (Pow(a, b - 1) * a) % MOD;
	__int64 half = Pow(a, b / 2) % MOD;
	return (half * half) % MOD;
}
__int64 nCr(__int64 n, __int64 r)
{
    __int64 A = 1; // A = n!, B = (n-r)!r!
    __int64 B = 1;
    __int64 ans;
    __int64 i;

    for(i=1;i<=n;i++)
    {
        A *= i;
        A %= MOD;
    }
    for(i=1;i<=n-r;i++)
    {
        B *= i;
        B %= MOD;
    }
    for(i=1;i<=r;i++)
    {
        B *= i;
        B %= MOD;
    }
    __int64 B2 = Pow(B, MOD-2);
    ans = (A * B2) % MOD;
    return ans;
}

int main(void)
{
    __int64 size, max;
    __int64 ans;

    scanf("%lld %lld", &size, &max);

    ans = nCr(max, size - 1) * (size-2) % MOD;
    ans = (ans * Pow(2, size-3)) % MOD;
    printf("%lld\n", ans);

    return 0;
}

#include <stdio.h>
#define MOD 998244353

__int64 Pow(__int64 a, __int64 b)
{
    __int64 half;
    if(b == 0) return 1;
    if(b % 2 == 1) return (Pow(a, b-1)*a) % MOD;
    half = Pow(a, b/2) % MOD;
    return (half * half) % MOD;
}
__int64 nCr(__int64 n, __int64 r)
{
    __int64 A = 1; // A = n!, B = (n-r)!r!
    __int64 B = 1;
    __int64 ans;
    __int64 i;

    for(i=1;i<=n;i++)
    {
        A *= i;
        A %= MOD;
    }
    for(i=1;i<=n-r;i++)
    {
        B *= i;
        B %= MOD;
    }
    for(i=1;i<=r;i++)
    {
        B *= i;
        B %= MOD;
    }
    __int64 B2 = Pow(B, MOD-2);
    ans = (A * B2) % MOD;
    return ans;
}

int main(void)
{
    __int64 size, max;
    __int64 ans;

    scanf("%lld %lld", &size, &max);

    ans = nCr(max, size - 1) * (size-2) % MOD;
    ans = (ans * Pow(2, size-3)) % MOD;
    printf("%lld\n", ans);

    return 0;
}

#include <stdio.h>

#define M	200000
#define MD	998244353

int d_, x_, y_;

void gcd_(int a, int b) {
	if (b == 0)
		d_ = a, x_ = 1, y_ = 0;
	else {
		int tmp;

		gcd_(b, a % b);
		tmp = x_ - a / b * y_, x_ = y_, y_ = tmp;
	}
}

int inv(int a) {
	gcd_(a, MD);
	return x_;
}

int p2[M * 2 + 1], ff[M * 2 + 1], gg[M * 2 + 1];

void init() {
	int i, f;

	p2[0] = 1;
	for (i = 1; i <= M * 2; i++)
		p2[i] = p2[i - 1] * 2 % MD;
	f = 1;
	for (i = 0; i <= M * 2; i++) {
		gg[i] = inv(ff[i] = f);
		f = (long long) f * (i + 1) % MD;
	}
}

long long choose(int n, int k) {
	return k < 0 || k > n ? 0 : (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;
}

int main() {
	int n, m, a, ans;

	init();
	scanf("%d%d", &n, &m);
	if (n == 2) {
		printf("0\n");
		return 0;
	}
	ans = 0;
	for (a = 2; a <= m; a++)
		ans = (ans + (a - 1) * choose(a - 2, n - 3) % MD * p2[n - 3]) % MD;
	if (ans < 0)
		ans += MD;
	printf("%d\n", ans);
	return 0;
}

#include<stdio.h>
const int m = 998244353;

int power( int x, int y ) {
	int a = 1;
	for( ; y>0; y>>=1, x=1ll*x*x %m )
		if( y&1 )
			a = 1ll*a*x %m;
	return a;
}

int fact( int n ) {
	int f = 1;
	for( int i=2; i<=n; ++i )
		f = 1ll*f*i %m;
	return f;
}

int main() {
	int N, M;
	scanf("%d%d", &N, &M);
	if( N == 2 ) { printf("0\n", M); return 0; }
	int ans = 1ll*(N-2)*power(2, N-3) %m;
	ans = 1ll*ans*fact(M) %m;
	ans = 1ll*ans*power(fact(M-N+1), m-2) %m;
	ans = 1ll*ans*power(fact(N-1), m-2) %m;
	printf("%d\n", ans);

}

#include <stdio.h>
#define MOD 998244353

__int64 Pow(__int64 a, __int64 b)
{
    __int64 ans=1;
    int i;
    for(i=0;i<b;i++)
    {
        ans *= a;
    }
    return ans;
}
__int64 nCr(__int64 n, __int64 r)
{
    __int64 A = 1; // A = n!, B = (n-r)!r!
    __int64 B = 1;
    __int64 ans;
    __int64 i;

    for(i=1;i<=n;i++)
    {
        A *= i;
        A %= MOD;
    }
    for(i=1;i<=n-r;i++)
    {
        B *= i;
        B %= MOD;
    }
    for(i=1;i<=r;i++)
    {
        B *= i;
        B %= MOD;
    }
    __int64 B2 = Pow(B, MOD-2);
    ans = (A * B2) % MOD;
    return ans;
}

int main(void)
{
    __int64 size, max;
    __int64 ans;

    scanf("%lld %lld", &size, &max);

    ans = nCr(max, size - 1) * (size-2) % MOD;
    ans = (ans * Pow(2, size-3)) % MOD;
    printf("%lld\n", ans);

    return 0;
}

#include <stdio.h>
#define MOD 998244353

__int64 Pow(__int64 a, __int64 b)
{
    __int64 ans=1;
    int i;
    for(i=0;i<b;i++)
    {
        ans *= b;
    }
    return ans;
}
__int64 nCr(__int64 n, __int64 r)
{
    __int64 A = 1; // A = n!, B = (n-r)!r!
    __int64 B = 1;
    __int64 ans;
    __int64 i;

    for(i=1;i<=n;i++)
    {
        A *= i;
        A %= MOD;
    }
    for(i=1;i<=n-r;i++)
    {
        B *= i;
        B %= MOD;
    }
    for(i=1;i<=r;i++)
    {
        B *= i;
        B %= MOD;
    }
    __int64 B2 = Pow(B, MOD-2);
    ans = (A * B2) % MOD;
    return ans;
}

int main(void)
{
    __int64 size, max;
    __int64 ans;

    scanf("%lld %lld", &size, &max);

    ans = nCr(max, size - 1) * (size-2) % MOD;
    ans = (ans * Pow(2, size-3)) % MOD;
    printf("%lld\n", ans);

    return 0;
}

#include <stdio.h>
#define MOD 998244353

__int64 Pow(__int64 a, __int64 b)
{
    __int64 ans=1;
    __int64 i;
    if (b == 0) return 1;
    for(i=0;i<b;i++)
    {
        ans *= a ;
    }
    return ans;
}
__int64 nCr(__int64 n, __int64 r)
{
    __int64 A = 1; // A = n!, B = (n-r)!r!
    __int64 B = 1;
    __int64 ans;
    __int64 i;

    for(i=1;i<=n;i++)
    {
        A *= i;
        A %= MOD;
    }
    for(i=1;i<=n-r;i++)
    {
        B *= i;
        B %= MOD;
    }
    for(i=1;i<=r;i++)
    {
        B *= i;
        B %= MOD;
    }
    __int64 B2 = Pow(B, MOD-2);
    ans = (A * B2) % MOD;
    return ans;
}

int main(void)
{
    __int64 size, max;
    __int64 ans;

    scanf("%lld %lld", &size, &max);

    ans = nCr(max, size - 1) * (size-2) % MOD;
    ans = (ans * Pow(2, size-3)) % MOD;
    printf("%lld\n", ans);

    return 0;
}

#include<stdio.h>
const int m = 998244353;

int power( int x, int y ) {
	int a = 1;
	for( ; y>0; y>>=1, x=1ll*x*x %m )
		if( y&1 )
			a = 1ll*a*x %m;
	return a;
}

int fact( int n ) {
	int f = 1;
	for( int i=2; i<=n; ++i )
		f = 1ll*f*i %m;
	return f;
}

int main() {
	int N, M;
	scanf("%d%d", &N, &M);
	if( N == 2 ) { printf("%d\n", M); return 0; }
	int ans = 1ll*(N-2)*power(2, N-3) %m;
	ans = 1ll*ans*fact(M) %m;
	ans = 1ll*ans*power(fact(M-N+1), m-2) %m;
	ans = 1ll*ans*power(fact(N-1), m-2) %m;
	printf("%d\n", ans);

}