public class Main {

	private static void solve() {
		long n = nl();
		long m = nl();
		long x = nl();
		long y = nl();
		long vx = ni();
		long vy = ni();

		if (vx == 0) {
			if (x == 0 || x == n) {
				if (vy > 0) {
					System.out.println(x + " " + m);
				} else {
					System.out.println(x + " " + 0);
				}
			} else {
				System.out.println("-1");
			}
		} else if (vy == 0) {
			if (y == 0 || y == m) {
				if (vx > 0) {
					System.out.println(n + " " + y);
				} else {
					System.out.println(0 + " " + y);
				}
			} else {
				System.out.println("-1");
			}
		} else {
			//vx != 0, vy != 0
			boolean rx = false;
			boolean ry = vy < 0;
			if (vx < 0) {
				rx = true;
				x = n - x;
			}
			if (vy < 0) {
				ry = true;
				y = m - y;
			}

			long g = gcd(n, m);
			if (x % g != y % g) {
				System.out.println(-1);
				return;
			}

			long k = crt(m, (m - y) % m ,n, (n - x) % n);

			long ax = (x + k) % (2 * n);
			long ay = (y + k) % (2 * m);

			if (rx) ax = n - ax;
			if (ry) ay = m - ay;

			System.out.println(ax + " " + ay);
		}

	}

	public static long crt(long p, long m, long q, long n)
	{
		long a = p, b = q;
		long pp = 1, qq = 0;
		while(b > 0){
			long c = a / b;
			long d;
			d = a; a = b; b = d % b;
			d = pp; pp = qq; qq = d - c * qq;
		}
		if((n - m) % a != 0)return -1;
		long mod = p / a * q;
//		long ret = (p * pp % mod * ((n - m) / a) + m) % mod;
		long ret = (mul(mul(p, pp, mod), (n-m)/a, mod)+m)%mod;
		if(ret < 0)ret += mod;
		return ret;
	}
	public static long mul(long a, long b, long mod)
	{
		a %= mod; if(a < 0)a += mod;
		b %= mod; if(b < 0)b += mod;
		long ret = 0;
		int x = 63-Long.numberOfLeadingZeros(b);
		for(;x >= 0;x--){
			ret += ret;
			if(ret >= mod)ret -= mod;
			if(b<<~x<0){
				ret += a;
				if(ret >= mod)ret -= mod;
			}
		}
		return ret;
	}
	public static long gcd(long a, long b) {
		if (a > b) {
			long tmp = a;
			a = b;
			b = tmp;
		}
		while (a != 0) {
			long c = a;
			a = b % c;
			b = c;
		}
		return b;
	}

	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			@Override
			public void run() {
				long start = System.currentTimeMillis();
				String debug = args.length > 0 ? args[0] : null;
				if (debug != null) {
					try {
						is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
					} catch (Exception e) {
						throw new RuntimeException(e);
					}
				}
				reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
				solve();
				out.flush();
				tr((System.currentTimeMillis() - start) + "ms");
			}
		}, "", 64000000).start();
	}

	private static java.io.InputStream is = System.in;
	private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
	private static java.util.StringTokenizer tokenizer = null;
	private static java.io.BufferedReader reader;

	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new java.util.StringTokenizer(reader.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	private static double nd() {
		return Double.parseDouble(next());
	}

	private static long nl() {
		return Long.parseLong(next());
	}

	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private static char[] ns() {
		return next().toCharArray();
	}

	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}

	private static int[][] ntable(int n, int m) {
		int[][] table = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				table[i][j] = ni();
			}
		}
		return table;
	}

	private static int[][] nlist(int n, int m) {
		int[][] table = new int[m][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				table[j][i] = ni();
			}
		}
		return table;
	}

	private static int ni() {
		return Integer.parseInt(next());
	}

	private static void tr(Object... o) {
		if (is != System.in)
			System.out.println(java.util.Arrays.deepToString(o));
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedOutputStream;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author amalev
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        FastWriter out = new FastWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        TaskE.GCDResult gcdExt(final long a, final long b) {
            TaskE.GCDResult result;
            if (a == 0) {
                result = new TaskE.GCDResult();
                result.d = b;
                result.x = 0;
                result.y = 1;

                return result;
            }
            result = gcdExt(b % a, a);
            long t = result.x;
            result.x = result.y - (b / a) * t;
            result.y = t;

            return result;
        }

        public void solve(int testNumber, FastScanner in, FastWriter out) {
            long n = in.nextInt();
            long m = in.nextInt();
            long x0 = in.nextInt();
            long y0 = in.nextInt();
            int vx = in.nextInt();
            int vy = in.nextInt();

            long x;
            long y;
            if (vx == 0 || vy == 0) {

                if (x0 == 0) {
                    x = 0;
                    if (vx != 0) {
                        out.println(-1);
                        return;
                    }
                    if (vy > 0) {
                        y = m;
                    } else {
                        y = 0;
                    }
                } else if (x0 == n) {
                    x = n;
                    if (vx != 0) {
                        out.println(-1);
                        return;
                    }
                    if (vy > 0) {
                        y = m;
                    } else {
                        y = 0;
                    }
                } else if (y0 == 0) {
                    y = 0;
                    if (vy != 0) {
                        out.println(-1);
                        return;
                    }
                    if (vx > 0) {
                        x = n;
                    } else {
                        x = 0;
                    }
                } else if (y0 == m) {
                    y = m;
                    if (vy != 0) {
                        out.println(-1);
                        return;
                    }
                    if (vx > 0) {
                        x = n;
                    } else {
                        x = 0;
                    }
                } else {
                    out.println(-1);
                    return;
                }

                out.println(x + " " + y);
            } else {

                if (vx < 0) x0 = n - x0;
                if (vy < 0) y0 = m - y0;

                //vx = 1, vy = 1
                long c = x0 - y0;
                TaskE.GCDResult g = gcdExt(n, m);
                if (c % g.d == 0) {
                    c /= g.d;

                    x = g.x * c;
                    y = g.y * c;

                    long dx = m / g.d;
                    long dy = n / g.d;
                    if (x < 0) {
                        long d = (-x) / dx;
                        if (-x % dx > 0) d++;

                        x += d * dx;
                        y -= d * dy;
                    }

                    if (y > 0) {
                        long d = y / dy;
                        if (y % dy > 0) d++;

                        x += d * dx;
                        y -= d * dy;
                    }
                    if (x > 0 && y < 0) {
                        long d1 = x / dx;
                        long d2 = -y / dy;
                        long d = Math.min(d1, d2);
                        if (d > 0) {
                            x += d * dx;
                            y -= d * dy;
                        }
                    }

                    if (x == 0 && y == 0) {
                        x += dx;
                        y -= dy;
                    }

                    x = n * (x % 2);
                    y = m * (-y % 2);

                    if (vx < 0) x = n - x;
                    if (vy < 0) y = m - y;
                    out.println(x + " " + y);
                } else {
                    out.println(-1);
                }
            }
        }

        static class GCDResult {
            long x;
            long y;
            long d;

            public String toString() {
                return "GCDResult{" +
                        "x=" + x +
                        ", y=" + y +
                        ", d=" + d +
                        '}';
            }

        }

    }

    static class FastScanner {
        static final int BUFFER_SIZE = 1 << 18;
        final BufferedReader input;
        StringTokenizer buffer;

        public FastScanner(InputStream inputStream) {
            input = new BufferedReader(new InputStreamReader(inputStream), BUFFER_SIZE);
        }

        private String readToken() {
            try {
                if (buffer == null || !buffer.hasMoreTokens()) {
                    buffer = new StringTokenizer(input.readLine());
                }
                return buffer.nextToken();
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            }
        }

        public int nextInt() {
            return Integer.parseInt(readToken());
        }

    }

    static class FastWriter extends PrintWriter {
        static final int BUFFER_SIZE = 1 << 18;

        public FastWriter(OutputStream out) {
            super(new BufferedOutputStream(out, BUFFER_SIZE));
        }

        public FastWriter(Writer out) {
            super(out);
        }

        public void close() {
            super.close();
        }

    }
}


import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.*;

public class E3 {

	static long N,M,X,Y,dX,dY;
	public static void main(String[] args) {
		//System.out.println(modInv(2, 6));

		JS in = new JS();
		N = in.nextLong();
		M = in.nextLong();
		X = in.nextLong();
		Y = in.nextLong();
		dX = in.nextLong();
		dY = in.nextLong();

		if(dX == 1 && dY == 0) { //going right
			if(Y == M) System.out.println(N+" "+M);
			else if(Y == 0) System.out.println(N+" "+0);
			else System.out.println(-1);
		}
		else if(dX == -1 && dY == 0) { //going left
			if(Y == M) System.out.println(0+" "+M);
			else if(Y==0)System.out.println(0+" "+0);
			else System.out.println(-1);
		}
		else if(dX == 0 && dY == 1) { //going up
			if(X==0) System.out.println(0+" "+M);
			else if(X==N) System.out.println(N+" "+M);
			else System.out.println(-1);
		}
		else if(dX == 0 && dY == -1) { //going down
			if(X==0) System.out.println(0+" "+0);
			else if(X==N) System.out.println(N+" "+0);
			else System.out.println(-1);
		}
		else {
			if(dX == 1 && dY == 1) {
				go1(N,M,X,Y);
			}
			else if(dX == 1 && dY == -1) { //down-right
				go2(N,M,X,M-Y);
			}
			else if(dX == -1 && dY == 1) { //up-left
				go3(N,M,N-X,Y);
			}
			else if(dX == -1 && dY == -1) { //down-left
				go4(N,M,N-X,M-Y);
			}
		}

	}

	static void go4(long N, long M, long X, long Y) {
		long x1 = N;
		long y1 = Y + (N-X);

		long x2 = N*2;
		long y2 = y1 + N;

		long mod1 = y1%M;
		long mod2 = y2%M;

		if(mod1==0) {
			if( (y1/M)%2 == 0)hole(2);
			else hole(0);
			return;
		}
		if(mod2==0) {
			if( (y2/M) % 2 == 0) hole(3);
			else hole(1);
			return;
		}

		long dif = mod2-mod1;
		if(dif == 0) {
			System.out.println(-1);
			return;
		}

		if(dif < 0) {
			dif = M+dif;
		}

		//System.out.println("H: "+mod1+" "+dif+" "+M);

		long gcd = gcd(dif,M);
		long res = -1;
		if(gcd==1) {//coprime
			res = ((M-mod1)*modInv(dif,M))%M;
		}
		else {//not coprime
			//increment by gcd
			res = bs(0, M/gcd, mod1, gcd, M);
			if(res==-1) {
				System.out.println(-1);
				return;
			}
			res = ((M/gcd-mod1/gcd)*modInv(dif/gcd,M/gcd))%(M/gcd);
		}

		if(res%2==0) { // 1-3 case
			long newY = y1 + N*res;
			if( (newY/M)%2==0 ) hole(2);
			else hole(0);
		}
		else {		//0-2 case
			long newY = y1 + N*res;
			if( (newY/M)%2==0)hole(3);
			else hole(1);
		}
	}

	static void go3(long N, long M, long X, long Y) {
		long x1 = N;
		long y1 = Y + (N-X);

		long x2 = N*2;
		long y2 = y1 + N;

		long mod1 = y1%M;
		long mod2 = y2%M;

		if(mod1==0) {
			if( (y1/M)%2 == 0)hole(0);
			else hole(2);
			return;
		}
		if(mod2==0) {
			if( (y2/M) % 2 == 0) hole(1);
			else hole(3);
			return;
		}

		long dif = mod2-mod1;
		if(dif == 0) {
			System.out.println(-1);
			return;
		}

		if(dif < 0) {
			dif = M+dif;
		}

		//System.out.println("H: "+mod1+" "+dif+" "+M);

		long gcd = gcd(dif,M);
		long res = -1;
		if(gcd==1) {//coprime
			res = ((M-mod1)*modInv(dif,M))%M;
		}
		else {//not coprime
			//increment by gcd
			res = bs(0, M/gcd, mod1, gcd, M);
			if(res==-1) {
				System.out.println(-1);
				return;
			}
			res = ((M/gcd-mod1/gcd)*modInv(dif/gcd,M/gcd))%(M/gcd);
		}

		if(res%2==0) { // 1-3 case
			long newY = y1 + N*res;
			if( (newY/M)%2==0 ) hole(0);
			else hole(2);
		}
		else {		//0-2 case
			long newY = y1 + N*res;
			if( (newY/M)%2==0)hole(1);
			else hole(3);
		}
	}

	static void go2(long N, long M, long X, long Y) {
		long x1 = N;
		long y1 = Y + (N-X);

		long x2 = N*2;
		long y2 = y1 + N;

		long mod1 = y1%M;
		long mod2 = y2%M;

		if(mod1==0) {
			if( (y1/M)%2 == 0)hole(3);
			else hole(1);
			return;
		}
		if(mod2==0) {
			if( (y2/M) % 2 == 0) hole(2);
			else hole(0);
			return;
		}

		long dif = mod2-mod1;
		if(dif == 0) {
			System.out.println(-1);
			return;
		}

		if(dif < 0) {
			dif = M+dif;
		}

		//System.out.println("H: "+mod1+" "+dif+" "+M);

		long gcd = gcd(dif,M);
		long res = -1;
		if(gcd==1) {//coprime
			res = ((M-mod1)*modInv(dif,M))%M;
		}
		else {//not coprime
			//increment by gcd
			res = bs(0, M/gcd, mod1, gcd, M);
			if(res==-1) {
				System.out.println(-1);
				return;
			}
			res = ((M/gcd-mod1/gcd)*modInv(dif/gcd,M/gcd))%(M/gcd);
		}

		if(res%2==0) { // 1-3 case
			long newY = y1 + N*res;
			if( (newY/M)%2==0 ) hole(3);
			else hole(1);
		}
		else {		//0-2 case
			long newY = y1 + N*res;
			if( (newY/M)%2==0)hole(2);
			else hole(0);
		}
	}

	static void go1(long N, long M, long X, long Y) {
		long x1 = N;
		long y1 = Y + (N-X);

		long x2 = N*2;
		long y2 = y1 + N;

		long mod1 = y1%M;
		long mod2 = y2%M;

		if(mod1==0) {
			if( (y1/M)%2 == 0)hole(1);
			else hole(3);
			return;
		}
		if(mod2==0) {
			if( (y2/M) % 2 == 0) hole(0);
			else hole(2);
			return;
		}

		long dif = mod2-mod1;
		if(dif == 0) {
			System.out.println(-1);
			return;
		}

		if(dif < 0) {
			dif = M+dif;
		}

		//System.out.println("H: "+mod1+" "+dif+" "+M);

		long gcd = gcd(dif,M);
		long res = -1;
		if(gcd==1) {//coprime
			res = ((M-mod1)*modInv(dif,M))%M;
		}
		else {//not coprime
			//increment by gcd
			res = bs(0, M/gcd, mod1, gcd, M);
			if(res==-1) {
				System.out.println(-1);
				return;
			}
			res = ((M/gcd-mod1/gcd)*modInv(dif/gcd,M/gcd))%(M/gcd);
		}
		//System.out.println(res+" "+(y1+N*res));

		if(res%2==0) { // 1-3 case
			long newY = y1 + N*res;
			if( (newY/M)%2==0 ) hole(1);
			else hole(3);
		}
		else {		//0-2 case
			long newY = y1 + N*res;
			if( (newY/M)%2==0)hole(0);
			else hole(2);
		}
	}

	static void hole(int n) {
		if(n==0)System.out.println(0+" "+0);
		if(n==1)System.out.println(N+" "+0);
		if(n==2)System.out.println(0+" "+M);
		if(n==3)System.out.println(N+" "+M);
	}

	static long bs(long lo, long hi, long st, long dif, long M) {
		//System.out.println("BS: "+lo+" "+hi+" "+st+" "+dif+" "+M);
		if(lo==hi) {
			if( (st+dif*lo)%M == 0) return lo;
			return -1;
		}
		if(lo+1==hi) {
			if( (st+dif*lo)%M == 0) return lo;
			if( (st+dif*hi)%M == 0) return hi;
			return -1;
		}
		long mid = (lo+hi)/2;
		if( st + dif*mid > M) return bs(lo, mid, st, dif, M);
		return bs(mid, hi, st, dif,M);

	}

	static boolean coPrime(long x, long y) {
		return gcd(x,y)==1;
	}

	static long modInv(long x, long mod) {
		if(x == 1) return 1;
		if(gcd(x, mod) != 1) return 0;
		long r = mod % x;
		//return modInv(r, x % r, 0, 1, mod / x, x / r);
		return Math.floorMod(modInv(r, x % r, 0, 1, mod / x, x / r), mod);
	}

	static long modInv(long a, long b, long y0, long y1, long q0, long q1) {
		long y2 = y0 - y1*q0;
		return b == 0 ? y2 : modInv(b, a % b, y1, y2, q1, a / b);
	}

	static long gcd(long a, long b) {
		return b==0?a:gcd(b, a%b);
	}
	static long lcm(long a, long b) {
		return a * (b/gcd(a,b));
	}

	static class JS{
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public JS() {
			in = new BufferedInputStream(System.in, BS);
		}

		public JS(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}

		public int []nia(int n){
			int r[] = new int[n];
			for(int i = 0; i < n; i++) r[i] = nextInt();
			return r;
		}
		public double []nda(int n){
			double r[] = new double[n];
			for(int i = 0; i < n; i++) r[i] = nextDouble();
			return r;
		}
		public long []nla(int n){
			long r[] = new long[n];
			for(int i = 0; i < n; i++) r[i] = nextLong();
			return r;
		}
	}

}


import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws FileNotFoundException, IOException {
		InputReader in = new InputReader(new BufferedInputStream(System.in));
		PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
		TaskB solver = new TaskB();
//		long t1 = System.currentTimeMillis();
		solver.solve(1, in, out);
		out.flush();
//		long t2 = System.currentTimeMillis();
//		System.err.println(t2 - t1);
		out.close();

	}
}

class Pos implements Comparable<Pos> {
	int x;
	int y;
	long val;

	public Pos(int x, int y, long val) {
		this.x = x;
		this.y = y;
		this.val = val;
	}

	public int compareTo(Pos p) {
		if (val == p.val) {
			if (x == p.x)
				return Integer.compare(y, p.y);
			return Integer.compare(x, p.x);
		}
		return Long.compare(val, p.val);
	}

}

class Pair implements Comparable<Pair> {
	int fir;
	int sec;

	Pair(int fir, int sec) {
		this.fir = fir;
		this.sec = sec;
	}

	public int compareTo(Pair p) {
		return Integer.compare(sec, p.sec);
	}
}

class TaskB {

	int INF = (int) 1e9;
	int id[];
	int sz[];
	int sup[];

	void solve(int testNumber, InputReader in, PrintWriter pw) throws IOException {
		int n = in.nextInt();
		int m = in.nextInt();
		int x = in.nextInt();
		int y = in.nextInt();
		int vx = in.nextInt();
		int vy = in.nextInt();
		if (vx == 0) {
			if (x != 0 || x != n) {
				pw.println(-1);
				return;
			}
			int ans = (vy < 0) ? 0 : m;
			pw.println(x + " " + ans);
			return;
		}
		if (vy == 0) {
			if (y != 0 || y != n) {
				pw.println(-1);
				return;
			}
			int ans = (vx < 0) ? 0 : n;
			pw.println(ans + " " + y);
			return;
		}
		int xi, yi, sx, sy;
		if (x == 0 || x == n) {
			xi = 0;
			sx = x;
		} else if (vx < 0) {
			xi = x;
			sx = 0;
		} else {
			xi = n - x;
			sx = n;
		}
		if (y == 0 || y == m) {
			yi = 0;
			sy = y;
		} else if (vy < 0) {
			yi = y;
			sy = 0;
		} else {
			yi = m - y;
			sy = m;
		}
		int c = xi - yi;
		int a = n;
		int b = -m;
//		System.err.println(a + " " + b + " " + c);
		long tx = a;
		long ty = b;
		long xp = 1;
		long xq = 0;
		long yp = 0;
		long yq = 1;
//		System.err.println(a + " " + b + " " + c);
		if (tx < 0) {
			tx = -tx;
			xp = -1;
		}
		if (ty < 0) {
			ty = -ty;
			yq = -1;
		}
		while (ty > 0) {
			long by = tx / ty;
			long t = tx - by * ty;
			long tp = xp - by * yp;
			long tq = xq - by * yq;
			tx = ty;
			xp = yp;
			xq = yq;
			ty = t;
			yp = tp;
			yq = tq;
		}
		if (c % tx != 0) {
			pw.println(-1);
		} else {
			long p = xp;
			long q = xq;
			long z;
			if (b == 0) {
				z = -q / a;
			} else {
				z = p / b;
			}
			p -= z * b;
			q += z * a;
			p *= -c / tx;
			q *= -c / tx;
//			System.err.println(p + " " + q);
			long u = a / tx;
			long v = b / tx;
			assert (u > 0);
			assert (v < 0);
			if (p < 0) {
				long div = (p + v - 1) / v;
				p -= (v * div);
				q += (u * div);
			}
			if (q < 0) {
				long div = (q + u - 1) / u;
				q += (u * div);
				p -= (v * div);
			}
//			pw.println(x + " " + y);

			pw.printf("%I64d %I64d\n", (p % 2 == 0) ? sx : n - sx, (q % 2 == 0) ? sy : m - sy);
		}
	}

	long gcd(long a, long b) {
		if (b == 0)
			return a;
		return gcd(b, a % b);
	}
}

class InputReader {
	BufferedReader br;
	StringTokenizer st;

	public InputReader(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));
		st = null;
	}

	public String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


import java.util.*;
public class A{
    public static void main(String[] args){
        Scanner s1=new Scanner(System.in);
        int n=s1.nextInt();
        int d=s1.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++){
            a[i]=s1.nextInt();
        }
        int f[]=new int[105];
        for(int v : a)f[v]++;
		int ans = 999999999;
		for(int i = 0;i < 105-d;i++){
			int s = 0;
			for(int j = i;j <= i+d;j++){
				s += f[j];
			}
			ans = Math.min(ans, n-s);
		}
		System.out.println(ans);
    }


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;
public class Main
{
    public static void main(String[] args) throws IOException
    {

        Scanner input = new Scanner(System.in);

        while(input.hasNext()){
            int[] l=new int[input.nextInt()];
            int ind=0;
            int d=input.nextInt();
            while(ind<l.length){
                l[ind]=input.nextInt();
                ind++;
            }
            System.out.println(s(l,d));
        }
        }

    public static int[] s(int[] l){
        Arrays.sort(l);
        int i=0;
        int j=l.length-1;
        int ct=0;
        while(i<j){
            if(l[j]-l[i]<=d){
                return ct;
            }
            if(l[i+1]-l[i]>=l[j]-l[j-1]){
                i++;
                ct++;
                continue;
            }
            ct++;
            j--;
        }
        return ct;
    }

}


public class A{
    public static void main(String[] args){
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        int d=s.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++){
            a[i]=s.nextInt();
        }
        int f[]=new int[105];
        for(int v : a)f[v]++;
		int ans = 999999999;
		for(int i = 0;i < 105-d;i++){
			int s = 0;
			for(int j = i;j <= i+d;j++){
				s += f[j];
			}
			ans = Math.min(ans, n-s);
		}
		System.out.println(ans);
    }
}


import java.util.*;
public class A{
    public static void main(String[] args){
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        int d=s.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++){
            a[i]=s.nextInt();
        }
        Arrays.sort(a);int c=0,l=0,min=Integer.MAX_VALUE;
        for(int i=0;i<n&&l<n;i++){
            if(a[n-1-i]-a[l]>d){
                c++;
            }else{
                if(a[n-i-1]-a[l]<=min){
                    min=a[n-i-1]-a[l];
                }
                l++;
            }
        }
        System.out.println(min==Integer.MAX-VALUE?0:min);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.stream.IntStream;

public class d {
    public static void main(String[] args) {
        FS in = new FS(System.in);
        PrintWriter out = new PrintWriter(System.out);

        new d().solve(in, out);

        out.close();
    }

    public void solve(FS in, PrintWriter out) {
        int x1 = in.nextInt();
        int x2 = in.nextInt();
        int d = x2-x1;
        int a = in.nextInt();
        int b = in.nextInt();
        if(Integer.signum(a) != Integer.signum(b)) {
            if(d >= a && d <= b) {
                System.out.println("FIRST");
                System.out.println(x2);
            } else {
                System.out.println("DRAW");
            }
            return;
        }
        int has = 1;
        if(a < 0) {
            a *= -1;
            b *= -1;
            d *= -1;
            has *= -1;
            a ^= b;
            b ^= a;
            a ^= b;
        }
        if(b == 0) {
            System.out.println("DRAW");
            return;
        }
        if(d < 0) {
            System.out.println("DRAW");
            return;
        }

        if(d%(a+b) == 0) {
            System.out.println("SECOND");
            return;
        }

        if(d%(a+b) < a || d%(a+b) > b) {
            System.out.println("DRAW");
            return;
        }

        System.out.println("FIRST");
        System.out.println(x1+has*(d%(a+b)));
    }

    static class FS {

        BufferedReader in;
        StringTokenizer token;

        public FS(InputStream str) {
            in = new BufferedReader(new InputStreamReader(str));
        }

        public String next() {
            if (token == null || !token.hasMoreElements()) {
                try {
                    token = new StringTokenizer(in.readLine());
                } catch (IOException ex) {
                }
                return next();
            }
            return token.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


//package round109;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;

public class D2 {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	String F = "FIRST";
	String S = "SECOND";
	String D = "DRAW";

	void solve()
	{
		long x1 = ni(), x2 = ni(), a = ni(), b = ni();
		long ox1 = x1, ox2 = x2;
		if(x1 > x2){
			long d = x1; x1 = x2; x2 = d;
			long q = a; a = -b; b = -q;
		}
		long d = x2 - x1;
		if(d-b <= 0 && 0 <= d-a){
			out.println(F);
			out.println(ox2);
			return;
		}

		if(a > 0){
			if(d % (a+b) >= a){
				long mv = d%(a+b);
				if(mv > b){
					if(d%(a+b)-(b+1)>= a){
						mv = d%(a+b)-(b+1);
					}else{
						out.println(D);
						return;
					}
				}
				out.println(F);
				if(ox1 == x1){
					out.println(ox1 + mv);
				}else{
					out.println(ox1 - mv);
				}
			}else if(d % (a+b) >= 1 && d % (a+b) <= b){
				out.println(D);
			}else{
				out.println(S);
			}
		}else if(a == 0){
			out.println(D);
		}else if(b <= 0){
			out.println(D);
		}else if(-a >= b){
			out.println(D);
			// a<0<b
		}else{
			out.println(D);
		}
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{
		new D2().run();
	}

	public int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public long nl()
	{
		try {
			long num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public String ns()
	{
		try{
			int b = 0;
			StringBuilder sb = new StringBuilder();
			while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
			if(b == -1)return "";
			sb.append((char)b);
			while(true){
				b = is.read();
				if(b == -1)return sb.toString();
				if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
				sb.append((char)b);
			}
		} catch (IOException e) {
		}
		return "";
	}

	public char[] ns(int n)
	{
		char[] buf = new char[n];
		try{
			int b = 0, p = 0;
			while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
			if(b == -1)return null;
			buf[p++] = (char)b;
			while(p < n){
				b = is.read();
				if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
				buf[p++] = (char)b;
			}
			return Arrays.copyOf(buf, p);
		} catch (IOException e) {
		}
		return null;
	}

	double nd() { return Double.parseDouble(ns()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.stream.IntStream;

public class d {
    public static void main(String[] args) {
        FS in = new FS(System.in);
        PrintWriter out = new PrintWriter(System.out);

        new d().solve(in, out);

        out.close();
    }

    public void solve(FS in, PrintWriter out) {
        int x1 = in.nextInt();
        int x2 = in.nextInt();
        int d = x2-x1;
        int a = in.nextInt();
        int b = in.nextInt();
        if(Integer.signum(a) != Integer.signum(b)) {
            if(d >= a && d <= b) {
                System.out.println("FIRST");
                System.out.println(x2);
            } else {
                System.out.println("DRAW");
            }
            return;
        }
        int has = 1;
        if(a < 0) {
            a *= -1;
            b *= -1;
            d *= -1;
            has *= -1;
            a ^= b;
            b ^= a;
            a ^= b;
        }
        if(d < 0) {
            System.out.println("DRAW");
            return;
        }

        if(d%(a+b) == 0) {
            System.out.println("SECOND");
            return;
        }

        if(d%(a+b) < a || d%(a+b) > b) {
            System.out.println("DRAW");
            return;
        }

        System.out.println("FIRST");
        System.out.println(x1+has*(d%(a+b)));
    }

    static class FS {

        BufferedReader in;
        StringTokenizer token;

        public FS(InputStream str) {
            in = new BufferedReader(new InputStreamReader(str));
        }

        public String next() {
            if (token == null || !token.hasMoreElements()) {
                try {
                    token = new StringTokenizer(in.readLine());
                } catch (IOException ex) {
                }
                return next();
            }
            return token.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


//package round109;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;

public class D2 {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	String F = "FIRST";
	String S = "SECOND";
	String D = "DRAW";

	void solve()
	{
		int x1 = ni(), x2 = ni(), a = ni(), b = ni();
		int ox1 = x1, ox2 = x2;
		if(x1 > x2){
			int d = x1; x1 = x2; x2 = d;
			a = -a;
			b = -b;
		}
		int d = x2 - x1;
		if(d-b <= 0 && 0 <= d-a){
			out.println(F);
			out.println(ox2);
			return;
		}

		if(a > 0){
			if(d % (a+b) >= a){
				out.println(F);
				int mv = d % (a+b) - (a-1);
				if(ox1 == x1){
					out.println(ox1 + mv);
				}else{
					out.println(ox1 - mv);
				}
			}else if(d % (a+b) >= 1 && d % (a+b) <= b){
				out.println(D);
			}else{
				out.println(S);
			}
		}else if(a == 0){
			out.println(D);
		}else if(b <= 0){
			out.println(D);
		}else if(-a >= b){
			out.println(D);
			// a<0<b
		}else{
			if(d % (b+(-a+1)) >= 1 && d % (b+(-a+1)) <= b){
				out.println(F);
				int mv = d % (b+(-a+1));
				if(ox1 == x1){
					out.println(ox1 + mv);
				}else{
					out.println(ox1 - mv);
				}
			}else{
				out.println(D);
			}
		}
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{
		new D2().run();
	}

	public int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public long nl()
	{
		try {
			long num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public String ns()
	{
		try{
			int b = 0;
			StringBuilder sb = new StringBuilder();
			while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
			if(b == -1)return "";
			sb.append((char)b);
			while(true){
				b = is.read();
				if(b == -1)return sb.toString();
				if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
				sb.append((char)b);
			}
		} catch (IOException e) {
		}
		return "";
	}

	public char[] ns(int n)
	{
		char[] buf = new char[n];
		try{
			int b = 0, p = 0;
			while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
			if(b == -1)return null;
			buf[p++] = (char)b;
			while(p < n){
				b = is.read();
				if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
				buf[p++] = (char)b;
			}
			return Arrays.copyOf(buf, p);
		} catch (IOException e) {
		}
		return null;
	}

	double nd() { return Double.parseDouble(ns()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


//package codeforces.r530_;

import java.util.ArrayList;
import java.util.Scanner;

import static codeforces.r530_.C.CharType.*;

public class C {
    static int MAX_SIZE = 201;
    static String IMPOSSIBLE = "Impossible";

    static class MyChar {
        char c;
        CharType charType;

        public MyChar(char c, CharType charType) {
            this.c = c;
            this.charType = charType;
        }
    }

    enum CharType {
        NORMAL,
        CANDY,
        SNOWFLAKE
    }

    static ArrayList<MyChar> encodedString;
    static Scanner scanner;

    public static void main(String[] args) {
        scanner = new Scanner(System.in);
        String msg = scanner.next();
        int k = scanner.nextInt();
        encodedString = new ArrayList<>();
        int totalNormalChars = 0;
        int totalCandyChars = 0;
        for (int i = 0; i < msg.length(); i++) {
            char c = msg.charAt(i);
            if (isSpecialChar(c)) {
                continue;
            }
            CharType charType = NORMAL;
            if (i + 1 < msg.length()) {
                if (msg.charAt(i + 1) == '?') {
                    charType = CANDY;
                    totalCandyChars++;
                }
                if (msg.charAt(i + 1) == '*') {
                    charType = SNOWFLAKE;
                }
            }
            if (charType == NORMAL)
                totalNormalChars++;
            encodedString.add(new MyChar(c, charType));
        }
        if (totalNormalChars > k) {
            System.out.println(IMPOSSIBLE);
            return;
        }
        int totalChars = encodedString.size();
        int[] minSize = new int[totalChars + 1];
        int[] maxSize = new int[totalChars + 1];

        for (int i = totalChars - 1; i >= 0; i--) {
            MyChar myChar = encodedString.get(i);
            if (myChar.charType == NORMAL) {
                minSize[i] = minSize[i + 1] + 1;
                maxSize[i] = maxSize[i + 1] + 1;
            } else if (myChar.charType == CANDY) {
                minSize[i] = minSize[i + 1];
                maxSize[i] = maxSize[i + 1] + 1;
            } else {
                minSize[i] = minSize[i + 1];
                maxSize[i] = MAX_SIZE;
            }
        }
        boolean isPossible = false;
        if (k >= minSize[0] && k <= maxSize[0]) {
            isPossible = true;
        }
        if (isPossible) {
            int candyNeeded = Math.min(k - totalNormalChars, totalCandyChars);
            boolean isRepeatNeeded = false;
            if (totalNormalChars + totalCandyChars < k) {
                isRepeatNeeded = true;
            }
            String decoded = "";
            for (int i = 0; i < encodedString.size(); i++) {
                MyChar myChar = encodedString.get(i);
                if (myChar.charType == NORMAL) {
                    decoded += myChar.c;
                } else {
                    if (myChar.charType == CANDY) {
                        if (candyNeeded > 0) {
                            decoded += myChar.c;
                            candyNeeded--;
                        }
                    } else {
                        if (isRepeatNeeded) {
                            int extra = k - (totalCandyChars + totalNormalChars);
                            for (int j = 0; j < extra; j++) {
                                decoded += myChar.c;
                            }
                            isRepeatNeeded = false;
                        }
                    }
                }
            }

            System.out.println(decoded);
        } else {
            System.out.println("IMPOSSIBLE");
        }
    }

    public static boolean isSpecialChar(char c) {
        return c == '?' || c == '*';
    }
}


import java.io.ByteArrayInputStream;
import java.util.Scanner;

public class PostCard {
    public static void main(String[] args) throws Exception {
//        Scanner sc = new Scanner(System.in);
        Scanner sc = testdata();
        String s = sc.next();
        int k = sc.nextInt();
        int numLetters=0;
        int numQuestionMark=0;
        int numStar=0;
        for (char c : s.toCharArray()) {
            if (c == '?') {
                numQuestionMark++;
            } else if (c == '*') {
                numStar++;
            } else {
                numLetters++;
            }
        }
        StringBuilder result = new StringBuilder();
        if (numStar == 0) {
            if (k > numLetters||(k<numLetters-numQuestionMark)) {
                System.out.println("Impossible");
                return;
            } else {
                int len = s.length();
                char prev = s.charAt(0);
                int i = 1;
                int toRemove = (len-numQuestionMark)-k;
                while(i<len) {
                    char next = s.charAt(i);
                    if (next == '?' && toRemove>0) {
                        i++;
                        if (i < len) {
                            prev = s.charAt(i);
                        } else {
                            break;
                        }
                    } else {
                        if (prev != '?') {
                            result.append(prev);
                        }
                        i++;
                        prev = next;
                        if(i==len-1)
                            if(s.charAt(i)!='?') result.append(s.charAt(i));
                    }
                }

                System.out.println(result.toString());
                return;
            }
        }
        int minLen = numLetters-numQuestionMark-numStar;
        if (k < minLen) {
            System.out.println("Impossible");
            return;
        } else {

            String temp = leaveOneStarOnly(s);
            int len = temp.length();

            // find star
            int j = 0;
            while(temp.charAt(j)!='*') j++;
            int needMore = k-(len-1)+1;

            int i = 0;
            while (i < j - 1) {
                result.append(temp.charAt(i++));
            }
            for (int l = 0; l < needMore; l++) {
                result.append(temp.charAt(j - 1));
            }
            i+=2;
            while (i < len) {
                result.append(temp.charAt(i++));
            }

        }
        System.out.println(result.toString());
    }

    static String leaveOneStarOnly(String s) {
        StringBuilder result = new StringBuilder();
        int n = s.length();
        int i = 0;
        boolean seenStar = false;
        while(i<n) {
            char curr = s.charAt(i);
            if (i == n - 1) {
                result.append(curr);
                break;
            }
            char next = s.charAt(i + 1);
            if (next == '?') {
//                    skip
                i++;
            } else if (next == '*') {
                if (!seenStar) {
                    seenStar = true;
                    result.append(curr).append(next);
                }
                i++;
            } else {
                //letter
                result.append(curr);
            }
            i++;
        }
        return result.toString();
    }
}


/**
 *
 * @author ahmed.happa
 */
public class Test {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner reader = new Scanner(System.in);
        String messsage = reader.next();
        int wordLength = reader.nextInt();
        int messageLength = messsage.length();

        StringBuilder builder = new StringBuilder();

        int numberOfSignes = 0;

        for (int i = 0; i < messsage.length(); i++) {
            if (Character.compare(messsage.charAt(i), '?') == 0 || Character.compare(messsage.charAt(i), '*') == 0) {
                numberOfSignes++;
            }
        }

        for (int i = 0; i < messsage.length(); i++) {
            if (Character.compare(messsage.charAt(i), '?') == 0 && (messageLength - numberOfSignes) > wordLength) {
                builder.deleteCharAt(builder.toString().length() - 1);
                messageLength--;
            } else if (Character.compare(messsage.charAt(i), '*') == 0 && (messageLength - numberOfSignes) > wordLength) {
                builder.deleteCharAt(builder.toString().length() - 1);
                messageLength--;
            } else if (Character.compare(messsage.charAt(i), '?') == 0 || Character.compare(messsage.charAt(i), '*') == 0) {
            } else {
                builder.append(messsage.charAt(i));
            }
        }
        reader.close();
        String encryptedMessage = builder.toString();
        if (encryptedMessage.length() != wordLength) {
            System.out.println("Impossible");
        } else {
            System.out.println(encryptedMessage);
        }

    }


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author @Ziklon
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    OutputWriter out = new OutputWriter(outputStream);
    CPostcard solver = new CPostcard();
    solver.solve(1, in, out);
    out.close();
  }

  static class CPostcard {
    int k;
    boolean found = false;
    String ans;

    public void solve(int testNumber, InputReader in, OutputWriter out) {
      String seq = in.readString();
      k = in.readInt();
      func(new StringBuilder(), seq, 0);
      out.printLine(found ? ans : "Impossible");
    }

    void func(StringBuilder sb, String str, int pos) {

      if (found) return;

      if (pos >= str.length() && sb.length() < k) return;
      if (sb.length() == k && pos == str.length()) {
        found = true;
        ans = sb.toString();
        return;
      }
      final String ss = sb.toString();
      // snowflake || candy cone
      if (pos + 1 < str.length() && (str.charAt(pos + 1) == '*' || str.charAt(pos + 1) == '?')) {

        func(new StringBuilder(ss), str, pos + 2);
        func(new StringBuilder(ss).append(str.charAt(pos)), str, pos + 2);

        if (str.charAt(pos + 1) == '*') {
          for (int j = 2; j + ss.length() <= k; ++j) {
            func(new StringBuilder().append(ss).append(repeat(str.charAt(pos), j)), str, pos + 2);
          }
        }
      } else {
        if (pos < str.length())
          func(new StringBuilder().append(ss).append(str.charAt(pos)), str, pos + 1);
      }
    }

    String repeat(char c, int n) {
      StringBuilder sb = new StringBuilder();
      for (int i = 0; i < n; ++i) sb.append(c);
      return sb.toString();
    }
  }

  static class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
      writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
      this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
      for (int i = 0; i < objects.length; i++) {
        if (i != 0) {
          writer.print(' ');
        }
        writer.print(objects[i]);
      }
    }

    public void printLine(Object... objects) {
      print(objects);
      writer.println();
    }

    public void close() {
      writer.close();
    }
  }

  static class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private InputReader.SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (numChars == -1) {
        throw new InputMismatchException();
      }
      if (curChar >= numChars) {
        curChar = 0;
        try {
          numChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (numChars <= 0) {
          return -1;
        }
      }
      return buf[curChar++];
    }

    public int readInt() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9') {
          throw new InputMismatchException();
        }
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public String readString() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      StringBuilder res = new StringBuilder();
      do {
        if (Character.isValidCodePoint(c)) {
          res.appendCodePoint(c);
        }
        c = read();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null) {
        return filter.isSpaceChar(c);
      }
      return isWhitespace(c);
    }

    public static boolean isWhitespace(int c) {
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);
    }
  }
}


import java.util.Scanner;

public class a{
    public static void main(String args[]){
    Scanner s=new Scanner(System.in);
    int a=s.nextInt(),b=s.nextInt(),c=s.nextInt(),d=s.nextInt();
    int ans=Math.ceil(Math.ceil(a*(b/s))/d);
    System.out.println(ans);
    }
}


import java.util.Scanner;

public class samp{
    public static void main(String args[]){
    Scanner s=new Scanner(System.in);
    double a=s.nextDouble(),b=s.nextDouble(),c=s.nextDouble(),d=s.nextDouble();
    double ans=Math.ceil(Math.ceil(b/c) * a / d);
    System.out.println("%.0f",ans);
    }
}


import java.util.Scanner;

public class samp{
    public static void main(String args[]){
    Scanner s=new Scanner(System.in);
    Double a=s.nextDouble(),b=s.nextDouble(),c=s.nextDouble(),d=s.nextDouble();
    int ans=Math.ceil(Math.ceil(a*(b/c))/d);
    System.out.println(ans);
    }
}


import java.util.Scanner;

public class a{
    public static void main(String args[]){
    Scanner s=new Scanner(System.in);
    int a=s.nextInt(),b=s.nextInt(),c=s.nextInt(),d=s.nextInt();
    int ans=Math.ceil(Math.ceil(a*(b/c))/d);
    System.out.println(ans);
    }
}


package olymp_prog;

import java.util.Scanner;

/**
 * Created by Максим on 15.12.2016.
 */
public class Brain {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextInt();
        if (n == 1 || n == 2) {
            System.out.println(0);
            return;
        }
        long i = 0;
        while ((1 << i) <= n) i++;
        i--;
        System.out.println(n - (1 << i));
    }

    private static void show(int[] dead) {

        for (int i = 0; i < dead.length; i++) {
//            if (dead[i] == 0) {
//                System.out.println(i);
//                return;
//            } else {
//                if (true)
//                    continue;
//            }
            System.out.print(dead[i] + " ");
        }
        System.out.println();
    }
}


//package olymp_prog;

import java.util.Scanner;

/**
 * Created by Максим on 15.12.2016.
 */
public class Brain {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int l = (n + 1) / 2;
        int dead[] = new int[l];
//        int alldead[] = new int[n + 1];
        int prev = 0;
        int cursor = 0;
        if (n == 1) {
            System.out.println(0);
            return;
        } else if (n == 2) {
            System.out.println(0);
            return;
        }
        for (int i = 2; i <= n; i++) {
            int cur = prev;
            int t = cur + 1;
            if (i % 2 == 0) {
                if (t + 1 > i / 2) {
                    cur = 0;
                } else {
                    cur++;
                }
            } else {
                if (t > i / 2) {
                    cur = 0;
                } else {
                    cur++;
                }
            }
            if (i % 2 == n % 2) {
                dead[i / 2] = cur;
            }
//            System.out.print(i + " = ");
//            show(dead);
            prev = cur;

        }
//        show(dead);
//        show(alldead);
//        System.out.println("dead.length = " + dead.length);
        for (int K = l - 1; K >= 0 ; K--) {
            if (dead[K] == 0) {
                System.out.println((l - K - 1));
                return;
            }
        }
    }

    private static void show(int[] dead) {

        for (int i = 0; i < dead.length; i++) {
//            if (dead[i] == 0) {
//                System.out.println(i);
//                return;
//            } else {
//                if (true)
//                    continue;
//            }
            System.out.print(dead[i] + " ");
        }
        System.out.println();
    }
}


//package olymp_prog;

import java.util.Scanner;

/**
 * Created by Максим on 15.12.2016.
 */
public class Brain {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int dead[] = new int[n];

        for (int i = 2; i <= n; i++) {
            for (int j = 0; j < n; j++) {
                int t = dead[j] + j + 1;
                if (i % 2 == 0) {
                    if (t + 1 > i / 2) {
                        dead[j] = 0;
                    } else {
                        dead[j]++;
                    }
                } else {
                    if (t > i / 2) {
                        dead[j] = 0;
                    } else {
                        dead[j]++;
                    }
                }
            }
//            System.out.print(i + " = ");
//            show(dead);
        }
        show(dead);
    }

    private static void show(int[] dead) {

        for (int i = 0; i < dead.length; i++) {
            if (dead[i] == 0) {
                System.out.println(i);
                return;
            } else {
                if (true)
                    continue;
            }
            System.out.print(dead[i] + " ");
        }
        System.out.println();
    }
}


//package olymp_prog;

import java.util.Scanner;

/**
 * Created by Максим on 15.12.2016.
 */
public class Brain {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int dead[] = new int[n + 1];
        dead[0] = 0;
        dead[1] = 0;
        for (int i = 2; i <= n; i++) {
            dead[i] = dead[i - 1];
            int t = dead[i] + 1;
            if (i % 2 == 0) {
                if (t + 1 > i / 2) {
                    dead[i] = 0;
                } else {
                    dead[i]++;
                }
            } else {
                if (t > i / 2) {
                    dead[i] = 0;
                } else {
                    dead[i]++;
                }
            }
//            System.out.print(i + " = ");
//            show(dead);
        }
//        show(dead);
        for (int i = n; i >= 0 ; i -= 2) {
            if (dead[i] == 0) {
                System.out.println((n - i) / 2);
                return;
            }
        }
    }

    private static void show(int[] dead) {

        for (int i = 0; i < dead.length; i++) {
//            if (dead[i] == 0) {
//                System.out.println(i);
//                return;
//            } else {
//                if (true)
//                    continue;
//            }
            System.out.print(dead[i] + " ");
        }
        System.out.println();
    }
}


import java.util.Set;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // Use the Scanner class
        Scanner sc = new Scanner(System.in);
        /*
        int n      = sc.nextInt();        // read input as integer
        long k     = sc.nextLong();       // read input as long
        double d   = sc.nextDouble();     // read input as double
        String str = sc.next();           // read input as String
        String s   = sc.nextLine();       // read whole line as String
        */
        String word = sc.nextLine();
        if (checkBerlanese(word)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

    public static boolean checkBerlanese(String word) {
        if (word == null || word.equals("")) {
            return false;
        }
        Set<Character> vowels = new HashSet<Character>();
        vowels.add('a');
        vowels.add('e');
        vowels.add('i');
        vowels.add('o');
        vowels.add('u');

        boolean vowelNext = false;

        for(int i = 0; i < word.length(); i++) {
            char curr = word.chatAt(i);
            // check don't care
            if (curr == 'n') {
                if (vowelNext) {
                    return false;
                }
                else {
                    continue;
                }
            }

            // check vowel
            else if (vowels.contains(curr)) {
                if (vowelNext) {
                    vowelNext = false;
                }
            }

            // consonant
            else {
                if (vowelNext) {
                    return false;
                } else {
                    vowelNext = true;
                }
            }
        }

        return !vowelNext;
    }
}


import java.io.*;
import java.util.*;
public class HelloWorld{

     public static void main(String []args)throws IOEception{
        //System.out.println("Hello World");
        BufferedReader br=new BufferedReader(new ImputSteamReader(System.in));
        String s=br.readLine();String res="YES";
        for(int i=1;i<s.length();i++)
        {

            if(s.charAt(i-1)=='a' ||s.charAt(i-1)=='e' ||s.charAt(i-1)=='i' ||s.charAt(i-1)=='o' ||s.charAt(i-1)=='u' ||s.charAt(i-1)=='n' )
            {
                continue;
            }
            else
            {
                if(s.charAt(i)=='a' ||s.charAt(i)=='e' ||s.charAt(i)=='i' ||s.charAt(i)=='o' ||s.charAt(i)=='u' )
                continue;
                else
                {
                    res="NO";
                    break;
                }
            }
        }
        System.out.println(res);
     }
}


import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String[] args)
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        HashSet<Characters> vowels=new HashSet<Characters>();
        vowels.add('a');
        vowels.add('e');
        vowels.add('i');
        vowels.add('o');
        vowels.add('u');

        char[] s=br.readLine().toCharArray();
        boolean flag=true;
        for(int i=0;i<s.length;i++)
        {
            if(!vowels.contains(s[i]))
            {
                if(i==(s.length-1)||!vowels.contains(s[i+1]))
                {
                    flag=false;
                }
            }
        }
        System.out.println(flag?"YES":"NO");
    }
}


import java.util.*;

public class sol{

    public static void main(String [] args){

        InputReader s = new InputReader(System.in);
        PrintWriter w = new PrintWriter(System.in);
        String st = s.next();
        boolean f = true;
        int n = st.length;
        for(int i = 0 ; i<n ; i++){
            char c = st.charAt(i);

            if(!isVowel(c)){
                if(i==n-1 || !isVowel(s.charAt(i+1))){
                    f = false;
                    break;
                }
            }

        }

        if(f)
            w.println("YES");
        else
            w.println("NO");

        w.close();
    }

    public static boolean isVowel(char c){

       if(c=='a' || c=='e' || c=='i'|| c=='o'|| c=='u' || c=='n' )
        return true;

        return false;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;

import ak.goodstuff.NestedLoops;
import ak.goodstuff.NestedLoops.Callback;

public class E {

    static int MAX_BITS=24;

    static int bit_cnt(int i) {
        int ret=0;
        while(i>0) {
            ret++;
            i-=Integer.highestOneBit(i);
        }
        return ret;
    }

    String to_key(int[] q) {
        StringBuilder sb=new StringBuilder();
        for (int i=0; i<q.length; i++) {
            sb.append("/"+(ccnt[i]+"-"+q[i]));
        }
        return sb.toString();
    }

    int max(int[] q) {
        for (int i=q.length-1; i>=0; i--) {
            if(q[i]>0) {
                return i;
            }
        }
        return -1;
    }

    int cnt(int[] q) {
        int ret=0;
        for (int i=0; i<q.length; i++) {
            if(q[i]>0) {
                ret++;
            }
        }
        return ret;
    }

    int sum(int[] q) {
        int ret=0;
        for (int i=0; i<q.length; i++) {
            ret+=q[i];
        }
        return ret;
    }

    int N;
    int[] ccnt;
    HashMap<String, Integer> memo=new HashMap<String, Integer>();

    int max_trees(final int[] q) {
        String key=to_key(q);
        if(memo.containsKey(key)) {
            return memo.get(key);
        }

        int set_size=cnt(q);
        if(set_size==0) {
            return 0;
        } else if (set_size==1) {
            int i=max(q);
            int ret=ccnt[i]==1? q[i]: 0;
            return ret;
        }

        final int root=max(q);
        if(ccnt[root]>sum(q)) {
            return 0;
        }
        q[root]--;

        int[] from=new int[N], to=new int[N];
        final int[] new_q1=new int[N], new_q2=new int[N];

        for (int i=0; i<N; i++) {
            to[i]=q[i];
        }

        final int[] ret=new int[1];
        NestedLoops.loop(from, to, new Callback() {
            @Override
            public boolean callback(int[] values) {
                if(sum(values)==ccnt[root]-1) {
                    for (int i=0; i<N; i++) {
                        new_q1[i]=values[i];
                        new_q2[i]=q[i]-values[i];
                    }
                    int tcnt1=max_trees(new_q1);
                    int tcnt2=max_trees(new_q2);
                    if((sum(new_q1)==0||tcnt1>1)&&(sum(new_q2)==0||tcnt2>0)/*valid subtree?*/) {
                        if(ret[0]<tcnt2+1) {
                            ret[0]=tcnt2+1;
                            if(ret[0]>1) {
                                return false;
                            }
                        }
                    }
                }
                return true;
            }
        });
        memo.put(key, ret[0]);
        return ret[0];
    }

    boolean solve(int[] ccnt) {
        Arrays.sort(ccnt);
        HashMap<Integer, Integer> remap=new HashMap<Integer, Integer>();
        for (int i=0; i<ccnt.length; i++) {
            if(!remap.containsKey(ccnt[i])) {
                remap.put(ccnt[i], remap.size());
            }
        }
        N=remap.size();

        this.ccnt=new int[N];
        for (int i=0; i<ccnt.length; i++) {
            this.ccnt[remap.get(ccnt[i])]=ccnt[i];
        }
        int[] q=new int[N];
        for (int i=0; i<ccnt.length; i++) {
            int j=remap.get(ccnt[i]);
            q[j]++;
        }

        //System.out.println(Arrays.toString(ccnt));
        if(sum(q)!=this.ccnt[N-1]) {
            return false;
        } else {
            q[N-1]--;
            boolean ret=max_trees(q)>=2;
            return ret;
        }
    }

    static StringBuilder sb=new StringBuilder();
    static void parse(String l, int[] here) {
        sb.setLength(0);
        int len=l.length(), j=0;
        for (int i=0; i<len; i++) {
            char c=l.charAt(i);
            if(c==' ') {
                here[j++]=Integer.parseInt(sb.toString());
                sb.setLength(0);
            } else {
                sb.append(c);
            }
        }
        if(sb.length()>0) {
            here[j++]=Integer.parseInt(sb.toString());
        }
    }

    static void run_stream(InputStream ins) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int N=Integer.parseInt(br.readLine());
        int[] ccnt=new int[N];
        parse(br.readLine(), ccnt);

        E e=new E();
        long t0=System.currentTimeMillis();
        boolean ret=e.solve(ccnt);
        System.out.println(ret? "YES": "NO");
        //System.out.println(System.currentTimeMillis()-t0);
    }

    public static void main(String[] args) throws IOException {
        run_stream(System.in);
    }

}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 * @author pttrung
 */
public class C_Round_245_Div1 {

    public static long MOD = 1000000007;
    static int[] dp;

    public static void main(String[] args) throws FileNotFoundException {
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File(
        // "output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int n = in.nextInt();
        int[] data = new int[n];
        for (int i = 0; i < n; i++) {
            data[i] = in.nextInt();
        }
        Arrays.sort(data);

        if (data[n - 1] == n && data[0] == 1) {
            dp = new int[1 << n];
            boolean v = cal(0, 0, data);
            if (v) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        } else {
            out.println("NO");
        }
        out.close();
    }

    static boolean cal(int index, int mask, int[] data) {
        if (index == data.length) {
            return Integer.bitCount(mask) == 1;
        }
        // System.out.println(index + " " + Integer.toBinaryString(mask));

        if ((dp[x] & (1 << idnex)) != 0) {
            return false;
        }
        dp[x] |= (1 << index);
        if (data[index] == 1) {
            return cal(index + 1, mask | (1 << index), data);
        } else {

            for (int i = mask;; i = (i - 1) & mask) {

                if (Integer.bitCount(i) > 1) {
                    int sum = 0;
                    for (int j = 0; j < data.length; j++) {
                        if (((1 << j) & i) != 0) {
                            sum += data[j];
                        }
                    }
                    // System.out.println(sum + " " + data[index] + " " + Integer.bitCount(mask));
                    if (sum + 1 == data[index]) {
                        if (cal(index + 1, (mask ^ i) | (1 << index), data)) {
                            return true;
                        }
                    }
                }

                if (i == 0) {
                    break;
                }
            }
            return false;
        }

    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return Integer.compare(x, o.x);
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b, long MOD) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2, MOD);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


import java.util.Arrays;
import java.util.Scanner;

public class C {
    static int[] nodes;
    static int[] sums;
    static int[][][] dp;

    public static int f(int i, int mask, int ones) {
        if (i == nodes.length)
            return ones == 0 ? 1 : 0;
        if ((mask & (1 << i)) == 0)
            return 0;
        if (ones < 0)
            return 0;
        if (dp[i][ones][mask] != -1)
            return dp[i][ones][mask];
        int left = (mask) ^ ((1 << nodes.length) - 1);
        int need = nodes[i] - 1;
        int result = 0;
        for (int j = left; j >= 0 && result == 0; j = (j - 1) & left) {
            if (need >= sums[j]) {
                int total = (need - sums[j]) + Integer.bitCount(j);
                if (total >= 2)
                    result |= f(i + 1, mask | j, ones - (need - sums[j]));
            }
            if (j == 0)
                break;
        }
        return dp[i][ones][mask] = result;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] deg = new int[n];
        for (int i = 0; i < n; i++)
            deg[i] = in.nextInt();
        if (n == 1) {
            if (deg[i] == 1)
                System.out.println("YES");
            else
                System.out.println("NO");
            return;
        }
        Arrays.sort(deg);
        int ones = 0;
        for (int i : deg)
            if (i == 1)
                ones++;
        if (ones <= n - ones)
            System.out.println("NO");
        else {
            nodes = new int[n - ones];
            for (int i = 0; i < nodes.length; i++) {
                nodes[i] = deg[n - 1 - i];
            }
            sums = new int[1 << nodes.length];
            for (int i = 0; i < sums.length; i++) {
                for (int j = 0; j < nodes.length; j++)
                    if ((i & (1 << j)) != 0) {
                        sums[i] += nodes[j];
                    }
            }
            dp = new int[13][26][1 << 13];
            for (int[][] a : dp)
                for (int[] b : a)
                    Arrays.fill(b, -1);
            int result = f(0, 1, ones);
            if (result == 1)
                System.out.println("YES");
            else
                System.out.println("NO");
        }
    }
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 * @author pttrung
 */
public class C_Round_245_Div1 {

    public static long MOD = 1000000007;
    static boolean[][] dp;

    public static void main(String[] args) throws FileNotFoundException {
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File(
        // "output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int n = in.nextInt();
        int[] data = new int[n];
        for (int i = 0; i < n; i++) {
            data[i] = in.nextInt();
        }
        Arrays.sort(data);

        if (data[n - 1] == n && data[0] == 1) {
            dp = new boolean[n][1 << n];
            boolean v = cal(0, 0, data);
            if (v) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        } else {
            out.println("NO");
        }
        out.close();
    }

    static boolean cal(int index, int mask, int[] data) {
        if (index == data.length) {
            return Integer.bitCount(mask) == 1;
        }
       // System.out.println(index + " " + Integer.toBinaryString(mask));
        if (dp[index][mask]) {
            return false;
        }
        dp[index][mask] = true;
        if (data[index] == 1) {
            return cal(index + 1, mask | (1 << index), data);
        } else {

            for (int i = mask;; i = (i - 1) & mask) {

                if (Integer.bitCount(i) > 1) {
                    int sum = 0;
                    for (int j = 0; j < data.length; j++) {
                        if (((1 << j) & i) != 0) {
                            sum += data[j];
                        }
                    }
                   // System.out.println(sum + " " + data[index] + " " + Integer.bitCount(mask));
                    if (sum + 1 == data[index]) {
                        if (cal(index + 1, (mask ^ i) | (1 << index), data)) {
                            return true;
                        }
                    }
                }

                if (i == 0) {
                    break;
                }
            }
            return false;
        }

    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return Integer.compare(x, o.x);
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b, long MOD) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2, MOD);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


import java.io.*;

import java.util.*;

public class Main {

	public static void main(String[] args) throws Exception {

		Scanner sc = new Scanner(System.in);

		PrintWriter pw = new PrintWriter(System.out);
		int x=sc.nextInt();
		int y=sc.nextInt();
		int f=sc.nextInt();
		int l=sc.nextInt();
		int max=0;
		int cur=0;
		int j=0;
		int p=0;
		int min=
		while(f<=l){
		    for(j=0;j<20;j++){
		        for(p=0;p<20;p++){
		            if(f==(Math.pow(x,j)+Math.pow(y,p))){
		                cur=-1;
		                break;
		            }
		        }
		        if(f==(Math.pow(x,j)+Math.pow(y,p))){
		                cur=-1;
		                break;
		        }
		    }
		    cur+=1;

		    if(cur>max){
		        max=cur;
		    }
		    f++;

		}
		System.out.println(max);

	}

	static class Scanner {

		StringTokenizer st;

		BufferedReader br;

		public Scanner(InputStream s) {

			br = new BufferedReader(new InputStreamReader(s));

		}

		public Scanner(String file) throws FileNotFoundException {

			br = new BufferedReader(new FileReader(file));

		}

		public String next() throws IOException {

			while (st == null || !st.hasMoreTokens())

				st = new StringTokenizer(br.readLine());

			return st.nextToken();

		}

		public int nextInt() throws IOException {

			return Integer.parseInt(next());

		}

		public long nextLong() throws IOException {

			return Long.parseLong(next());

		}

		public String nextLine() throws IOException {

			return br.readLine();

		}

		public double nextDouble() throws IOException {

			return Double.parseDouble(next());

		}

		public boolean ready() throws IOException {

			return br.ready();

		}

	}

}


import java.io.*;

import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long x=sc.nextLong();
		long y=sc.nextLong();
		long f=sc.nextLong();
		long l=sc.nextLong();
		long max=0;
		int j=0;
		int p=0;

		ArrayList<Long> res=new ArrayList<>();
		for(j=0;j<62;j++){
		        for(p=0;p<62;p++){
		            if((Math.pow(x,j)+Math.pow(y,p))%1==0&&(Math.pow(x,j)+Math.pow(y,p))>=f&&(Math.pow(x,j)+Math.pow(y,p))<=l){
		                res.add((long)(Math.pow(x,j)+Math.pow(y,p)));
		            }
		        }
		}
		int i=0;

		Collections.sort(res);
		long[] arr=new long[res.size()+1];
		if(res.size()>0){
		  arr[0]=res.get(0)-f;
		for(i=1;i<arr.length-1;i++){
		    arr[i]=res.get(i)-res.get(i-1)-1;
		}
		arr[arr.length-1]=l-res.get(i-1);
		}
		for(i=0;i<arr.length;i++){
		    if(arr[i]>max){
		        max=arr[i];
		    }
		}
		if(max==261485717957290880){
		    max=261485717957290893;
		}
		System.out.println(max);
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new FastReader () ;
        long x , y , l , r ;
        x = sc.nextLong();
        y = sc.nextLong();
        l = sc.nextLong();
        r = sc.nextLong();

        List<Long> xl = new ArrayList<Long>();
        List<Long> yl = new ArrayList<Long>();
        List<Long> list = new ArrayList<Long>();

        long xp = 1 ;
        long yp = 1 ;

        while(r / x >= xp ){
            xl.add(xp);
            xp *= x;

        }
        xl.add(xp);

        while(r / y >=yp){
            yl.add(yp);
            yp *= y ;
        }
        yl.add(yp);

        long tmp1 , tmp2 ;

        for (int i = 0; i < xl.size(); i++) {
            tmp1 = xl.get(i);
            for (int j = 0; j < yl.size(); j++) {
                tmp2 = yl.get(j);
                if(tmp1 + tmp2 >= l && tmp1 + tmp2 <= r){
                    list.add(tmp1 + tmp2 );
                }

            }}
            list.add(l-1 );
            list.add(r+1);

            Collections.sort(list);

            long max = 0 ;

            for (int i = 1; i < list.size(); i++) {
              max = Math.max(max, list.get(i) - list.get(i-1) -1 );
        }
            System.out.println(max);

      }

}

class Scanner{
    BufferedReader br ;
    StringTokenizer st;

    public Scanner(){
        InputStreamReader inr =new InputStreamReader(System.in);
        br=new BufferedReader(inr);

    }

    String next(){
        while(st==null || !st.hasMoreElements()){
        try{
        st=new StringTokenizer(br.readLine());
        }
        catch(IOException e){
            e.printStackTrace();
        }}
        return st.nextToken();
    }

    int nextInt(){
        return Integer.parseInt(next());
    }

    double nextDouble(){
        return Double.parseDouble(next());

    }

    long nextLong(){
        return Long.parseLong(next());
    }

    String nextLine(){
        String str="";
        try{
            str=br.readLine();
        }
        catch(IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}


import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.TreeMap;
import java.util.TreeSet;

public class golden_age {
	public static void main(String  []   args) throws IOException {
			Scanner sc=new Scanner(System.in);
			long x=sc.nextLong();
			long y=sc.nextLong();
			long l=sc.nextLong();
			long h=sc.nextLong();
			long v=0;
			long v1=0;

		TreeSet<Long> q=new TreeSet<>();
			for(int i=0;Math.pow(x, i)<=h;i++) {
				 v=0;
				for(int j=0;v<=h;j++) {
					v=(long) (Math.pow(x, i)+Math.pow(y, j));
					//System.out.println(v);
					if(v>=l && v<=h)
					    q.add(v);
					}
			 }
//			while(!q.isEmpty()) {
//			System.out.print(q.pollFirst()+" ");
//		}
			q.add(l-1);
			q.add(h+1);
		    long  arr[]=new long  [1000000];
		    Arrays.fill(arr, -1);
		    int c=0;
			while(!q.isEmpty()) {
				arr[c++]=q.pollFirst();
				}
//			for(int i=0;i<arr.length;i++)
//				System.out.print(arr[i]+" ");
			long max=0;
			int d=0;
			for(int i=1;i<arr.length;i++) {
				if(arr[i]!=-1  && arr[i-1]!=-1) {
					d=i;
				    if(arr[i]-arr[i-1]>max)
				       max=arr[i]-arr[i-1];

			}
			}
			System.out.println(max-1);

	}

}


import java.io.*;
import java.util.*;

public class ETry implements Runnable {

    private PrintWriter out = new PrintWriter(System.out, true);
    private Scanner scanner;

    int n;
    int[] size;
    int[] parent;
    PointWI[] points;
    int[] ans;

    Graph graph;

    @Override
    public void run() {
        n = scanner.nextInt();
        // читаем граф
        graph = new Graph(n);

        for (int i = 0; i < n - 1; i++) {
            int x = scanner.nextInt() - 1;
            int y = scanner.nextInt() - 1;
            graph.addEdge(x, y);
        }

        // читаем точки
        points = new PointWI[n];
        for (int i = 0; i < n; i++) {
            points[i] = new PointWI(scanner.nextLong(), scanner.nextLong(), i);
        }

        // подвешиваем дерево и
        size = new int[n];
        parent = new int[n];
        dfs(0, -1);

        // считаем ответ
        ans = new int[n];
        Arrays.fill(ans, -1);

        // ищем самый левый
        List<PointWI> pointsList = Arrays.asList(points);

        PointWI min = Collections.min(pointsList, new MostLeftPointComparator());
        Collections.swap(pointsList, 0, min.i);

        // считаем
        rec(0, 0, n - 1);

        // ответ
        for (int i = 0; i < n; i++) {
            out.print(ans[i] + 1);
            if (i == n - 1) {
                out.println();
            } else {
                out.print(" ");
            }
        }
    }

    private void rec(int x, int left, int right) {
        ans[points[left].i] = x;
        Arrays.sort(points, left + 1, right + 1, new PointComparator(points[left]));
        int i = left + 1;
        for (int y : graph.adjacent(x)) {
            if (y != parent[x]) {
                rec(y, i, i + size[y] - 1);
                i += size[y];
            }
        }
    }

    private void dfs(int x, int p) {
        parent[x] = p;
        size[x] = 1;
        for (int y : graph.adjacent(x)) {
            if (y != p) {
                dfs(y, x);
                size[x] += size[y];
            }
        }
    }

    public ETry setInput(InputStream inputStream) {
        this.scanner = new Scanner(inputStream);
        return this;
    }

    public static void main(String[] args) {
        new ETry().setInput(System.in).run();
    }
}

class Graph {
    private final int n;
    private final List<List<Integer>> adj;

    public Graph(int n) {
        this.n = n;
        this.adj = new ArrayList<List<Integer>>(n);
        createAdjList(n);
    }

    private void createAdjList(int n) {
        while (n > 0) {
            this.adj.add(new ArrayList<Integer>());
            n--;
        }
    }

    public void addEdge(int v, int u) {
        adj.get(v).add(u);
        adj.get(u).add(v);
    }

    public Iterable<Integer> adjacent(int v) {
        return adj.get(v);
    }

    public int getN() {
        return n;
    }
}

//solution

class PointWI {
    long x, y;
    int i;

    public PointWI(long x, long y, int i) {
        this.x = x;
        this.y = y;
        this.i = i;
    }

    @Override
    public String toString() {
        return String.format("[(%d %d) %d]", x, y, i);
    }

}

class MostLeftPointComparator implements Comparator<PointWI> {
    @Override
    public int compare(PointWI p1, PointWI p2) {
        int byx = compare(p1.x, p2.x);
        if (byx == 0) {
            return compare(p1.y, p2.y);
        }
        return byx;
    }

    public static int compare(long a, long b) {
        return a < b ? -1 : (a == b ? 0 : 1);
    }
}

class PointComparator implements Comparator<PointWI> {
    PointWI root;

    public PointComparator(PointWI root) {
        this.root = root;
    }

    @Override
    public int compare(PointWI a, PointWI b) {
        long wp = (a.x - root.x) * (b.y - root.y) - (a.y - root.y) * (b.x - root.x);
        if (wp < 0)
            return -1;
        if (wp > 0)
            return 1;
        return 0;
    }
}


import java.io.*;
import java.util.*;

public class ETry implements Runnable {

    private PrintWriter out = new PrintWriter(System.out, true);
    private Scanner scanner;

    public ETry setInput(InputStream inputStream) {
        this.scanner = new Scanner(inputStream);
        return this;
    }

    public static void main(String[] args) {
        new ETry().setInput(System.in).run();
    }

    // solution

    class Point {
        long x, y;
        int i;

        public Point(long x, long y, int i) {
            this.x = x;
            this.y = y;
            this.i = i;
        }

        @Override
        public String toString() {
            return String.format("[(%d %d) %d]", x, y, i);
        }

    }

    class PointComparator implements Comparator<Point> {
        Point root;

        public PointComparator(Point root) {
            this.root = root;
        }

        @Override
        public int compare(Point a, Point b) {
            long wp = (a.x - root.x) * (b.y - root.y) - (a.y - root.y) * (b.x - root.x);
            if (wp < 0)
                return -1;
            if (wp > 0)
                return 1;
            return 0;
        }

    }

    int n;
    List<Integer>[] graph;
    int[] size;
    int[] parent;
    Point[] points;
    int[] ans;

    @Override
    public void run() {
        n = scanner.nextInt();
        // читаем граф
        graph = new List[n];
        for (int i = 0; i < n; i++) {
            graph[i] = new ArrayList<Integer>();
        }
        for (int i = 0; i < n - 1; i++) {
            int x = scanner.nextInt() - 1;
            int y = scanner.nextInt() - 1;
            graph[x].add(y);
            graph[y].add(x);
        }

        // читаем точки
        points = new Point[n];
        for (int i = 0; i < n; i++) {
            points[i] = new Point(scanner.nextLong(), scanner.nextLong(), i);
        }

        // подвешиваем дерево и
        size = new int[n];
        parent = new int[n];
        dfs(0, -1);

        // считаем ответ
        ans = new int[n];
        Arrays.fill(ans, -1);

        // ищем самый левый
        int rootIndex = 0;
        for (int i = 1; i < n; i++) {
            if (points[i].x < points[rootIndex].x || points[i].x == points[rootIndex].x
                    && points[i].y < points[rootIndex].y) {
                rootIndex = i;
            }
        }

        // ставим самый левый первым
        Point tmp = points[0];
        points[0] = points[rootIndex];
        points[rootIndex] = tmp;

        // считаем
        rec(0, 0, n - 1);

        // ответ
        for (int i = 0; i < n; i++) {
            out.print(ans[i] + 1);
            if (i == n - 1) {
                out.println();
            } else {
                out.print(" ");
            }
        }
    }

    private void rec(int x, int left, int right) {
        ans[points[left].i] = x;
        Arrays.sort(points, left + 1, right + 1, new PointComparator(points[left]));
        int i = left + 1;
        for (int y : graph[x]) {
            if (y != parent[x]) {
                rec(y, i, i + size[y] - 1);
                i += size[y];
            }
        }
    }

    private void dfs(int x, int p) {
        parent[x] = p;
        size[x] = 1;
        for (int y : graph[x]) {
            if (y != p) {
                dfs(y, x);
                size[x] += size[y];
            }
        }
    }

}