using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    private static void SolveA()
    {
        var n = RI();
        var m = RI() - 1;
        int k = RI();
        var a = RIA(n);

        var answer = int.MaxValue;
        for (int i = 0; i < n; i++)
            if (a[i] > 0 && a[i] <= k)
            {
                answer = Math.Min(answer, 10 * (Math.Abs(i - m)));
            }

        Console.WriteLine(answer);
    }

    private static void SolveB()
    {
        var n = RI();
        var m = RI();
        int k = RI();
        var h = new HashSet<int>(RIA(m));

        int pos = 1;
        for (int i = 0; i < k; i++)
        {
            if (h.Contains(pos))
                break;

            var u = RI();
            var v = RI();

            if (pos == u) pos = v;
            else if (pos == v) pos = u;
        }

        Console.WriteLine(pos);
    }

    private static void SolveC()
    {

    }

    private static void Main(string[] args)
    {
        SolveB();
    }

    private const int Mod = 1000000000 + 7;

    #region Data Read
    private static char ReadSign()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans == '+' || ans == '-' || ans == '?')
                return (char)ans;
        }
    }

    private static long GCD(long a, long b)
    {
        if (a % b == 0) return b;
        return GCD(b, a % b);
    }

    private static List<int>[] ReadGraph(int n, int m)
    {
        List<int>[] g = new List<int>[n];
        for (int i = 0; i < g.Length; i++) g[i] = new List<int>();
        for (int i = 0; i < m; i++)
        {
            int a = RI() - 1;
            int b = RI() - 1;

            g[a].Add(b);
            g[b].Add(a);
        }

        return g;
    }

    private static int[,] ReadGraphAsMatrix(int n, int m)
    {
        int[,] matrix = new int[n + 1, n + 1];
        for (int i = 0; i < m; i++)
        {
            int a = RI();
            int b = RI();
            matrix[a, b] = matrix[b, a] = 1;
        }

        return matrix;
    }

    private static void Sort(ref int a, ref int b)
    {
        if (a > b) Swap(ref a, ref b);
    }

    private static void Swap(ref int a, ref int b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }

    private const int BufferSize = 1 << 16;
    private static StreamReader consoleReader;
    private static MemoryStream testData;

    private static int RI()
    {
        int ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static ulong RUL()
    {
        ulong ans = 0;
        int chr;
        do
        {
            chr = consoleReader.Read();
            if (chr == -1)
                return 0;
        } while (chr < '0' || chr > '9');

        ans = (uint)(chr - '0');
        while (true)
        {
            chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans;
            ans = ans * 10 + (uint)(chr - '0');
        }
    }

    private static long RL()
    {
        long ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static int[] RIA(int n)
    {
        int[] ans = new int[n];
        for (int i = 0; i < n; i++)
            ans[i] = RI();
        return ans;
    }

    private static long[] RLA(int n)
    {
        long[] ans = new long[n];
        for (int i = 0; i < n; i++)
            ans[i] = RL();
        return ans;
    }

    private static char[] ReadWord()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        List<char> s = new List<char>();
        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s.ToArray();
    }

    private static char[] ReadString(int n)
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        char[] s = new char[n];
        int pos = 0;
        do
        {
            s[pos++] = (char)ans;
            if (pos == n) break;
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s;
    }

    private static char[] ReadStringLine()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (ans == 10 || ans == 13);

        List<char> s = new List<char>();

        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while (ans != 10 && ans != 13 && ans != -1);

        return s.ToArray();
    }

    private static char ReadLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))
                return (char)ans;
        }
    }
    private static char ReadNonLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')))
                return (char)ans;
        }
    }

    private static char ReadAnyOf(IEnumerable<char> allowed)
    {
        while (true)
        {
            char ans = (char)consoleReader.Read();
            if (allowed.Contains(ans))
                return ans;
        }
    }

    private static char ReadDigit()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans >= '0' && ans <= '9')
                return (char)ans;
        }
    }

    private static int ReadDigitInt()
    {
        return ReadDigit() - (int)'0';
    }

    private static char ReadAnyChar()
    {
        return (char)consoleReader.Read();
    }

    private static string DoubleToString(double x)
    {
        return x.ToString(CultureInfo.InvariantCulture);
    }

    private static double DoubleFromString(string x)
    {
        return double.Parse(x, CultureInfo.InvariantCulture);
    }

    static Program()
    {
        //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);
    }

    private static void PushTestData(StringBuilder sb)
    {
        PushTestData(sb.ToString());
    }
    private static void PushTestData(string data)
    {
#if TOLYAN_TEST
        if (testData == null)
        {
            testData = new MemoryStream();
            consoleReader = new StreamReader(testData);
        }

        var pos = testData.Position;
        var bytes = Encoding.UTF8.GetBytes(data);
        testData.Write(bytes, 0, bytes.Length);
        testData.Flush();
        testData.Position = pos;
#endif
    }
    #endregion
}


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

object Main {
    var `in`: IO? = null
    var out: PrintWriter? = null

    @Throws(Exception::class)
    fun init_io(filename: String) {
        if (filename == "") {
            `in` = IO(System.`in`)
            out = PrintWriter(BufferedWriter(OutputStreamWriter(System.out)), true)
        } else {
            `in` = IO(FileInputStream("$filename.in"))
            out = PrintWriter(BufferedWriter(FileWriter("$filename.out")), true)
        }
    }

    const val mod: Long = 998244353

    /*
fun main(args: Array<String>) {
    Main.main(args);
}
*/
    @Throws(Exception::class)
    fun solve(tc: Int) {
        val n = `in`!!.nint()
        val m = `in`!!.nint()
        val k = `in`!!.nint()
        val hole = BooleanArray(n + 1)
        for (i in 0 until m) {
            val x = `in`!!.nint()
            hole[x] = true
        }
        var pos = 1
        for (i in 0 until k) {
            val x = `in`!!.nint()
            val y = `in`!!.nint()
            if (!hole[pos]) {
                if (pos == x) pos = y else if (pos == y) pos = x
            }
        }
        out!!.println(pos)
    }

    @Throws(Exception::class)
    @JvmStatic
    fun main(_u_n_u_s_e_d_: Array<String>) {
        init_io("")
        val t = 1
        // t = in.nint();
        for (tc in 0 until t) {
            solve(tc)
        }
    }

    fun minv(v: Long): Long {
        return mpow(v, mod - 2)
    }

    fun mpow(base: Long, exp: Long): Long {
        var base = base
        var exp = exp
        var res: Long = 1
        while (exp > 0) {
            if (exp and 1 == 1L) {
                res = res * base % mod
            }
            base = base * base % mod
            exp = exp shr 1
        }
        return res
    }

    fun gcd(x: Long, y: Long): Long {
        return if (x == 0L) y else gcd(y % x, x)
    }

    fun rsort(arr: LongArray) {
        val r = Random()
        for (i in arr.indices) {
            val j = i + r.nextInt(arr.size - i)
            val t = arr[i]
            arr[i] = arr[j]
            arr[j] = t
        }
        Arrays.sort(arr)
    }

    fun rsort(arr: IntArray) {
        val r = Random()
        for (i in arr.indices) {
            val j = i + r.nextInt(arr.size - i)
            val t = arr[i]
            arr[i] = arr[j]
            arr[j] = t
        }
        Arrays.sort(arr)
    }

    /* static void qsort(long[] arr) {
    Long[] oarr = new Long[arr.length];
    for (int i = 0; i < arr.length; i++) {
      oarr[i] = arr[i];
    }

    ArrayList<Long> alist = new ArrayList<Long>(Arrays.asList(oarr));
    Collections.sort(alist);

    for (int i = 0; i < arr.length; i++) {
      arr[i] = (long)alist.get(i);
    }
  } */
    fun reverse(arr: LongArray) {
        for (i in 0 until arr.size / 2) {
            val temp = arr[i]
            arr[i] = arr[arr.size - 1 - i]
            arr[arr.size - 1 - i] = temp
        }
    }

    fun atos(arr: LongArray?): String {
        var s = Arrays.toString(arr)
        s = s.substring(1, s.length - 1)
        return s.replace(",", "")
    }

    class IO(x: InputStream?) {
        var `in`: BufferedReader
        var tokens: StringTokenizer

        @Throws(Exception::class)
        fun nint(): Int {
            return nstr().toInt()
        }

        @Throws(Exception::class)
        fun nlong(): Long {
            return nstr().toLong()
        }

        @Throws(Exception::class)
        fun ndouble(): Double {
            return nstr().toDouble()
        }

        @Throws(Exception::class)
        fun nstr(): String {
            if (!tokens.hasMoreTokens()) tokens = StringTokenizer(`in`.readLine())
            return tokens.nextToken()
        }

        @Throws(Exception::class)
        fun nla(n: Int): LongArray {
            val arr = LongArray(n)
            for (i in 0 until n) {
                arr[i] = nlong()
            }
            return arr
        }

        init {
            `in` = BufferedReader(InputStreamReader(x))
            tokens = StringTokenizer(`in`.readLine())
        }
    }

    internal class Pair<A : Comparable<A>?, B : Comparable<B>?>(var f: A, var s: B) : Comparable<Pair<A, B>> {
        override fun compareTo(other: Pair<A, B>): Int {
            val v = f!!.compareTo(other.f)
            return if (v != 0) v else s!!.compareTo(other.s)
        }

        override fun toString(): String {
            return "(" + f.toString() + ", " + s.toString() + ")"
        }

    }
}

fun main(args: Array<String>) {
    Main.main(args);
}


import jdk.nashorn.internal.runtime.JSType.toLong
import sun.security.jgss.GSSToken.readInt
import java.util.*
import kotlin.math.sqrt

fun main(args : Array<String>){

  var i=0
    var n:Int
    var o=Scanner(System.`in`)
     n=o.nextInt()
    var m=o.nextInt()
    var k=o.nextInt()
    var a=Array(n+1,{i->i*0})
    var b:Int
    for(i in 0..(m-1)){
       b =o.nextInt()
        a[b]=1;
    }
    var x:Int=0
    var y:Int=0
    var flag:Int=0
   for(i in 1..k){
       x =o.nextInt()
       y=o.nextInt()
       if(a[x]==1){
           print("$x")
           flag=1
           break;
       }else{
           if(a[y]==1){
               print("$y")
               flag=1
               break;
           }
       }
   }
 //   print("$flag")
if(flag==0){
    print("$y")
}
}


import jdk.nashorn.internal.runtime.JSType.toLong
import sun.security.jgss.GSSToken.readInt
import java.util.*
import kotlin.math.sqrt

fun main(args : Array<String>){

  var i=0
    var n:Int
    var o=Scanner(System.`in`)
     n=o.nextInt()
    var m=o.nextInt()
    var k=o.nextInt()
    var a=Array(n+1,{i->i*0})
    var b:Int
    for(i in 0..(m-1)){
       b =o.nextInt()
        a[b]=1;
    }
    var x:Int=0
    var y:Int=0
    var flag:Int=0
    var w=0
   for(i in 1..k) {
       x = o.nextInt()
       y = o.nextInt()
       if (x == 1 || w == 1) {
           if (a[x] == 1) {
               print("$x")
               flag = 1
               break;
           } else {
               if (a[y] == 1) {
                   print("$y")
                   flag = 1
                   break;
               }
           }
           w = 1;
       }
   }
 //   print("$flag")
    if(w==0 && flag==0){
        print("1")
    }else {
        if (flag == 0) {
            print("$y")
        }
    }
}


import jdk.nashorn.internal.runtime.JSType.toLong
import sun.security.jgss.GSSToken.readInt
import java.util.*
import kotlin.math.sqrt

fun main(args : Array<String>){

  var i=0
    var n:Int
    var o=Scanner(System.`in`)
     n=o.nextInt()
    var m=o.nextInt()
    var k=o.nextInt()
    var a=Array(n+1,{i->i*0})
    var b:Int
    for(i in 0..(m-1)){
       b =o.nextInt()
        a[b]=1;
    }
    var x:Int=0
    var y:Int=0
    var flag:Int=0
    var w=1
    var ans:Int=1;
   for(i in 1..k) {
       x = o.nextInt()
       y = o.nextInt()
      if(ans==x){
          if(a[x]!=1){
              ans=y
          }
      }else{
          if(ans==y){
              if(a[y]!=1){
                  ans=x;
              }
          }
      }
   }
 print(("$ans"))

}


import jdk.nashorn.internal.runtime.JSType.toLong
import sun.security.jgss.GSSToken.readInt
import java.util.*
import kotlin.math.sqrt

fun main(args : Array<String>){

  var i=0
    var n:Int
    var o=Scanner(System.`in`)
     n=o.nextInt()
    var m=o.nextInt()
    var k=o.nextInt()
    var a=Array(n+1,{i->i*0})
    var b:Int
    for(i in 0..(m-1)){
       b =o.nextInt()
        a[b]=1;
    }
    var x:Int=0
    var y:Int=0
    var flag:Int=0
    var w=0
   for(i in 1..k) {
       x = o.nextInt()
       y = o.nextInt()
       if (x == 1 || w == 1 || y==1) {
           if (a[x] == 1) {
               print("$x")
               flag = 1
               break;
           } else {
               if (a[y] == 1) {
                   print("$y")
                   flag = 1
                   break;
               }
           }
           w = 1;
       }
   }
 //   print("$flag")
    if(w==0 && flag==0){
        print("1")
    }else {
        if (flag == 0) {
            print("$y")
        }
    }
}


import java.lang.String.format
import java.util.*
import kotlin.math.*
import kotlin.system.exitProcess

private fun readLn()=readLine()!! // string line
private fun readInt()=readLn().toInt() // single int
private fun readLong()=readLn().toLong() // single long
private fun readDouble()=readLn().toDouble() // single double
private fun readStrings()=readLn().split(" ") // list of strings
private fun readInts()=readStrings().map { it.toInt() } // list of ints
private fun readLongs()=readStrings().map { it.toLong() } // list of longs
private fun readDoubles()=readStrings().map { it.toDouble() } // list of doubles
fun main(){
    val reader=Scanner(System.`in`)
    var (n,m,k)=readInts()
    var h=Array<Int>(n+1){0}
    for(i in 1..m){
        var b=reader.nextInt()
        h[b]=1
    }
    var a=1
    for(i in 1..k){
        if(h[a]==1){
            print(a)
            return
        }
        var b=reader.nextInt()
        var c=reader.nextInt()
        if(a==b){
            a=c
        }
        else{
            if(a==c){
                a=b
            }
        }
    }
    print(a)
}


fun main() {
    val (_, _, numSwaps) = readLine()!!.split(" ").map(String::toInt)
    val holes = readLine()!!.split(" ").map(String::toInt).toSet()
    var pos = 1
    for (swap in 1..numSwaps) {
        val (from, to) = readLine()!!.split(" ").map(String::toInt)
        if (from == pos)
            pos = to
        else if (to == pos)
            pos = from
        if (pos in holes) break
    }
    print(pos)
}


fun main() {
    val (_, _, numSwaps) = readLine()!!.split(" ").map(String::toInt)
    val holes = readLine()!!.split(" ").map(String::toInt).toSet()
    var pos = 1
    for (swap in 1..numSwaps) {
        if (pos in holes) break
        val (from, to) = readLine()!!.split(" ").map(String::toInt)
        if (from == pos)
            pos = to
        else if (to == pos)
            pos = from
    }
    print(pos)
}


fun main() {
    val (_, _, numSwaps) = readLine()!!.split(" ").map(String::toInt)
    val holes = readLine()!!.split(" ").map(String::toInt).toSet()
    var pos = 1
    for (swap in 1..numSwaps) {
        val (from, to) = readLine()!!.split(" ").map(String::toInt)
        if (from == pos) {
            pos = to
            if (pos in holes) break
        }
    }
    print(pos)
}


fun main(){
var (n,m,k)=readLine()!!.split(' ').map(String::toInt)
var a = readLine()!!.split(' ').map(String::toInt)
    var b = IntArray(n + 1) { 0 }
    for(i in 0..m-1){
    b[a[i]]=1
    }
    var x:Int
    var y:Int
    var c:Int
    var l:Int
    c=1
    while(k-->0){
    var(x,y)=readLine()!!.split(' ').map(String::toInt)
    l=b[c]
    if(l>0){
    print(c)
    return
    }
    if(c==x) c=y
    else if(c==y) c=x
    }
    print(c)
}


fun main(args: Array<String>) {
    val (n, m, k) = readLine()!!.split(" ").map(String::toInt)
    val h = readLine()!!.split(" ").map(String::toInt).toSet()

    var ans = 1

    for (i in 0..k - 1) {
        val (u, v) = readLine()!!.split(" ").map(String::toInt)

        if (h.contains(ans)) {
            continue
        }

        if (ans == u) {
            ans = v
        } else if (ans == v) {
            ans = u
        }
    }

    println(ans)
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
void merge(int* a,int n1,int *b,int n2,int *c)
{
    int n=n1+n2,i,j=0,k=0;
    for(i=0;i<n;i++)
    {
        if(j!=n1&&k!=n2)
        {
        if(a[j]>b[k]){c[i]=b[k],k++;}
        else c[i]=a[j],j++;
        }
        else break;
    }
    if(j==n1 && i!=n)
    {
        while(k!=n2){c[i]=b[k],i++,k++;}
    }
    else if(k==n2 && i!=n)
        {
           while(j!=n1){c[i]=a[j],i++,j++;}
        }
    return;
}
void merge_sort(int* a,int n,int *b)
{
    if(n==1){b[0]=a[0];return;}
    int *a1=(int*)malloc((n/2)*sizeof(int));
    int *a2=(int*)malloc((n-n/2)*sizeof(int));
    merge_sort(&a[0],n/2,a1);
    merge_sort(&a[n/2],n-n/2,a2);
    merge(a1,n/2,a2,n-n/2,b);
    return;
}

int main() {

    /* Enter your code here. Read input from STDIN. Print output to STDOUT */
    int n,m,k,i,y=0,z=0;
    scanf("%d %d %d",&n,&m,&k);
    int b[m];
    for(i=0;i<m;i++)
    {
        scanf("%d",b+i);
    }
    int *a=(int *)malloc(n*sizeof(int));
    merge_sort(b,n,a);
    int c,d;
    for(i=0;i<k;i++)
    {
        scanf("%d %d",&c,&d);
        int mid,lt=0,rt=n-1;
        while(lt<=rt)
        {
            mid=(lt+rt)/2;
            if(a[mid]==d){z=1;break;}
            else if(a[mid]>d){rt=mid-1;}
            else lt=mid+1;
        }
        if(z==1){break;}
    }
    printf("%d",d);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
void merge(int* a,int n1,int *b,int n2,int *c)
{
    int n=n1+n2,i,j=0,k=0;
    for(i=0;i<n;i++)
    {
        if(j!=n1&&k!=n2)
        {
        if(a[j]>b[k]){c[i]=b[k],k++;}
        else c[i]=a[j],j++;
        }
        else break;
    }
    if(j==n1 && i!=n)
    {
        while(k!=n2){c[i]=b[k],i++,k++;}
    }
    else if(k==n2 && i!=n)
        {
           while(j!=n1){c[i]=a[j],i++,j++;}
        }
    return;
}
void merge_sort(int* a,int n,int *b)
{
    if(n==1){b[0]=a[0];return;}
    int *a1=(int*)malloc((n/2)*sizeof(int));
    int *a2=(int*)malloc((n-n/2)*sizeof(int));
    merge_sort(&a[0],n/2,a1);
    merge_sort(&a[n/2],n-n/2,a2);
    merge(a1,n/2,a2,n-n/2,b);
    return;
}

int main() {

    /* Enter your code here. Read input from STDIN. Print output to STDOUT */
    int n,m,k,i,y=0,z=0;
    scanf("%d %d %d",&n,&m,&k);
    int b[m];
    for(i=0;i<m;i++)
    {
        scanf("%d",b+i);
    }
    int *a=(int *)malloc(m*sizeof(int));
    merge_sort(b,m,a);
    int c,d;
    for(i=0;i<k;i++)
    {
        scanf("%d %d",&c,&d);
        int mid,lt=0,rt=n-1;
        while(lt<=rt)
        {
            mid=(lt+rt)/2;
            if(a[mid]==d){z=1;break;}
            else if(a[mid]>d){rt=mid-1;}
            else lt=mid+1;
        }
        if(z==1){break;}
    }
    printf("%d",d);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
void merge(int* a,int n1,int *b,int n2,int *c)
{
    int n=n1+n2,i,j=0,k=0;
    for(i=0;i<n;i++)
    {
        if(j!=n1&&k!=n2)
        {
        if(a[j]>b[k]){c[i]=b[k],k++;}
        else c[i]=a[j],j++;
        }
        else break;
    }
    if(j==n1 && i!=n)
    {
        while(k!=n2){c[i]=b[k],i++,k++;}
    }
    else if(k==n2 && i!=n)
        {
           while(j!=n1){c[i]=a[j],i++,j++;}
        }
    return;
}
void merge_sort(int* a,int n,int *b)
{
    if(n==1){b[0]=a[0];return;}
    int *a1=(int*)malloc((n/2)*sizeof(int));
    int *a2=(int*)malloc((n-n/2)*sizeof(int));
    merge_sort(&a[0],n/2,a1);
    merge_sort(&a[n/2],n-n/2,a2);
    merge(a1,n/2,a2,n-n/2,b);
    return;
}
int ls(int temp,int *a,int m)
{
    int mid,lt=0,rt=m-1;
            while(lt<=rt)
            {
                mid=(lt+rt)/2;
                if(a[mid]==temp){return 1;}
                else if(a[mid]>temp){rt=mid-1;}
                else lt=mid+1;
            }
    return 0;
}

int main() {

    /* Enter your code here. Read input from STDIN. Print output to STDOUT */
    int n,m,k,i,y=0,z=0;
    scanf("%d %d %d",&n,&m,&k);
    int *b=(int *)malloc(m*sizeof(int));
    for(i=0;i<m;i++)
    {
        scanf("%d",b+i);
    }
    int *a=(int *)malloc(m*sizeof(int));
    merge_sort(b,m,a);
    free(b);
    int c,d,temp=1;
    for(i=0;i<k;i++)
    {
        scanf("%d %d",&c,&d);
        if(temp==1)
        {
            if(ls(temp,a,m)==1){break;}
            else{if(c==temp){temp=d;if(ls(temp,a,m)==1){break;}}
            else{if(d==temp){temp=c;if(ls(temp,a,m)==1){break;}}
                 else continue;}}
        }
        else
        {
        if(c==temp){temp=d;}
        else if(d==temp){temp=c;}
        else continue;

        if(d<a[0]||d>a[m-1]){continue;}
        else
        {
            z=ls(temp,a,m);
            if(z==1){break;}
        }
        }
    }
    printf("%d",temp);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
void merge(int* a,int n1,int *b,int n2,int *c)
{
    int n=n1+n2,i,j=0,k=0;
    for(i=0;i<n;i++)
    {
        if(j!=n1&&k!=n2)
        {
        if(a[j]>b[k]){c[i]=b[k],k++;}
        else c[i]=a[j],j++;
        }
        else break;
    }
    if(j==n1 && i!=n)
    {
        while(k!=n2){c[i]=b[k],i++,k++;}
    }
    else if(k==n2 && i!=n)
        {
           while(j!=n1){c[i]=a[j],i++,j++;}
        }
    return;
}
void merge_sort(int* a,int n,int *b)
{
    if(n==1){b[0]=a[0];return;}
    int *a1=(int*)malloc((n/2)*sizeof(int));
    int *a2=(int*)malloc((n-n/2)*sizeof(int));
    merge_sort(&a[0],n/2,a1);
    merge_sort(&a[n/2],n-n/2,a2);
    merge(a1,n/2,a2,n-n/2,b);
    return;
}
int ls(int temp,int *a,int m)
{
    int mid,lt=0,rt=m-1;
            while(lt<=rt)
            {
                mid=(lt+rt)/2;
                if(a[mid]==temp){return 1;}
                else if(a[mid]>temp){rt=mid-1;}
                else lt=mid+1;
            }
    return 0;
}

int main() {

    /* Enter your code here. Read input from STDIN. Print output to STDOUT */
    int n,m,k,i,y=0,z=0;
    scanf("%d %d %d",&n,&m,&k);
    int b[m];
    for(i=0;i<m;i++)
    {
        scanf("%d",b+i);
    }
    int *a=(int *)malloc(m*sizeof(int));
    merge_sort(b,m,a);
    int c,d,temp=1;
    for(i=0;i<k;i++)
    {
        scanf("%d %d",&c,&d);
        if(temp==1)
        {
            if(ls(temp,a,m)==1){break;}
            else{if(c==temp){temp=d;if(ls(temp,a,m)==1){break;}}
            else{if(d==temp){temp=c;if(ls(temp,a,m)==1){break;}}
                 else continue;}}
        }
        else
        {
        if(c==temp){temp=d;}
        else if(d==temp){temp=c;}
        else continue;

        if(d<a[0]||d>a[m-1]){continue;}
        else
        {
            z=ls(temp,a,m);
            if(z==1){break;}
        }
        }
    }
    printf("%d",temp);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
void merge(int* a,int n1,int *b,int n2,int *c)
{
    int n=n1+n2,i,j=0,k=0;
    for(i=0;i<n;i++)
    {
        if(j!=n1&&k!=n2)
        {
        if(a[j]>b[k]){c[i]=b[k],k++;}
        else c[i]=a[j],j++;
        }
        else break;
    }
    if(j==n1 && i!=n)
    {
        while(k!=n2){c[i]=b[k],i++,k++;}
    }
    else if(k==n2 && i!=n)
        {
           while(j!=n1){c[i]=a[j],i++,j++;}
        }
    return;
}
void merge_sort(int* a,int n,int *b)
{
    if(n==1){b[0]=a[0];return;}
    int *a1=(int*)malloc((n/2)*sizeof(int));
    int *a2=(int*)malloc((n-n/2)*sizeof(int));
    merge_sort(&a[0],n/2,a1);
    merge_sort(&a[n/2],n-n/2,a2);
    merge(a1,n/2,a2,n-n/2,b);
    return;
}

int main() {

    /* Enter your code here. Read input from STDIN. Print output to STDOUT */
    int n,m,k,i,y=0,z=0;
    scanf("%d %d %d",&n,&m,&k);
    int b[m];
    for(i=0;i<m;i++)
    {
        scanf("%d",b+i);
    }
    int *a=(int *)malloc(m*sizeof(int));
    merge_sort(b,m,a);
    int c,d;
    for(i=0;i<k;i++)
    {
        scanf("%d %d",&c,&d);
        if(d<a[0]||d>a[m-1]){continue;}
        else
        {
        int mid,lt=0,rt=m-1;
        while(lt<=rt)
        {
            mid=(lt+rt)/2;
            if(a[mid]==d){z=1;break;}
            else if(a[mid]>d){rt=mid-1;}
            else lt=mid+1;
        }
        if(z==1){break;}
        }
    }
    printf("%d",d);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
void merge(int* a,int n1,int *b,int n2,int *c)
{
    int n=n1+n2,i,j=0,k=0;
    for(i=0;i<n;i++)
    {
        if(j!=n1&&k!=n2)
        {
        if(a[j]>b[k]){c[i]=b[k],k++;}
        else c[i]=a[j],j++;
        }
        else break;
    }
    if(j==n1 && i!=n)
    {
        while(k!=n2){c[i]=b[k],i++,k++;}
    }
    else if(k==n2 && i!=n)
        {
           while(j!=n1){c[i]=a[j],i++,j++;}
        }
    return;
}
void merge_sort(int* a,int n,int *b)
{
    if(n==1){b[0]=a[0];return;}
    int *a1=(int*)malloc((n/2)*sizeof(int));
    int *a2=(int*)malloc((n-n/2)*sizeof(int));
    merge_sort(&a[0],n/2,a1);
    merge_sort(&a[n/2],n-n/2,a2);
    merge(a1,n/2,a2,n-n/2,b);
    return;
}

int main() {

    /* Enter your code here. Read input from STDIN. Print output to STDOUT */
    int n,m,k,i,y=0,z=0;
    scanf("%d %d %d",&n,&m,&k);
    int b[m];
    for(i=0;i<m;i++)
    {
        scanf("%d",b+i);
    }
    int *a=(int *)malloc(m*sizeof(int));
    merge_sort(b,m,a);
    int c,d,temp=1;
    for(i=0;i<k;i++)
    {
        scanf("%d %d",&c,&d);
        if(c==temp){temp=d;}
        else if(d==temp){temp=c;}
        else continue;

        if(d<a[0]||d>a[m-1]){continue;}
        else
        {
            int mid,lt=0,rt=m-1;
            while(lt<=rt)
            {
                mid=(lt+rt)/2;
                if(a[mid]==temp){z=1;break;}
                else if(a[mid]>temp){rt=mid-1;}
                else lt=mid+1;
            }
            if(z==1){break;}
        }

    }
    printf("%d",temp);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
void merge(int* a,int n1,int *b,int n2,int *c)
{
    int n=n1+n2,i,j=0,k=0;
    for(i=0;i<n;i++)
    {
        if(j!=n1&&k!=n2)
        {
        if(a[j]>b[k]){c[i]=b[k],k++;}
        else c[i]=a[j],j++;
        }
        else break;
    }
    if(j==n1 && i!=n)
    {
        while(k!=n2){c[i]=b[k],i++,k++;}
    }
    else if(k==n2 && i!=n)
        {
           while(j!=n1){c[i]=a[j],i++,j++;}
        }
    return;
}
void merge_sort(int* a,int n,int *b)
{
    if(n==1){b[0]=a[0];return;}
    int *a1=(int*)malloc((n/2)*sizeof(int));
    int *a2=(int*)malloc((n-n/2)*sizeof(int));
    merge_sort(&a[0],n/2,a1);
    merge_sort(&a[n/2],n-n/2,a2);
    merge(a1,n/2,a2,n-n/2,b);
    return;
}

int main() {

    /* Enter your code here. Read input from STDIN. Print output to STDOUT */
    int n,m,k,i,y=0,z=0;
    scanf("%d %d %d",&n,&m,&k);
    int b[m];
    for(i=0;i<m;i++)
    {
        scanf("%d",b+i);
    }
    int *a=(int *)malloc(m*sizeof(int));
    merge_sort(b,m,a);
    int c,d;
    for(i=0;i<k;i++)
    {
        scanf("%d %d",&c,&d);
        if(d<a[0]||d>a[m-1]){continue;}
        else
        {
        int mid,lt=0,rt=n-1;
        while(lt<=rt)
        {
            mid=(lt+rt)/2;
            if(a[mid]==d){z=1;break;}
            else if(a[mid]>d){rt=mid-1;}
            else lt=mid+1;
        }
        if(z==1){break;}
        }
    }
    printf("%d",d);
    return 0;
}


#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
int cmp(const void *a, const void *b)
{
	return ( *(int*)a - *(int*)b );
}
int min(int a,int b)
{
	if(a<=b)
		return a;
	else
		return b;
}
int max(int a,int b)
{
	if(a>=b)
		return a;
	else
		return b;
}
int main()
{
	int n,m,k,i,u,v,temp,num_swaps,bone_pos,flag,hole[1000005];
	scanf("%d %d %d",&n,&m,&k);		// number of cups, holes, swaps
	for(i=0;i<=m;i++)
		hole[i]=0;
	for(i=0;i<m;i++)
	{
		scanf("%d",&temp);
		hole[temp-1]=1;			// 0 indexed
	}
	num_swaps=0;
	bone_pos=0;		// at index 0 initially
	flag=0;			// bone can move
	while(num_swaps<k)
	{
		scanf("%d %d",&u,&v);
		u=u-1;		// converting to indexes
		v=v-1;
		if(hole[bone_pos]==1)
		{
			flag=1;
			if(k==300000)
			{
				printf("Hole at bone_pos %d\n",bone_pos);
				break;
			}
		}
		if( ((u==bone_pos)||(v==bone_pos)) && (flag==0) )
		{
			bone_pos=u+v-bone_pos;
		}
		num_swaps++;
		if((k==300000)&&(k-num_swaps<10))
			printf("u and v are %d %d\n",u+1,v+1);
	}
	printf("%d\n",bone_pos+1);
	return 0;
}


#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
int cmp(const void *a, const void *b)
{
	return ( *(int*)a - *(int*)b );
}
int min(int a,int b)
{
	if(a<=b)
		return a;
	else
		return b;
}
int max(int a,int b)
{
	if(a>=b)
		return a;
	else
		return b;
}
int main()
{
	int n,m,k,i,u,v,temp,num_swaps,bone_pos,flag,hole[1000005];
	scanf("%d %d %d",&n,&m,&k);		// number of cups, holes, swaps
	for(i=0;i<=m;i++)
		hole[i]=0;
	for(i=0;i<m;i++)
	{
		scanf("%d",&temp);
		hole[temp-1]=1;			// 0 indexed
	}
	num_swaps=0;
	bone_pos=0;		// at index 0 initially
	flag=0;			// bone can move
	while(num_swaps<k)
	{
		scanf("%d %d",&u,&v);
		u=u-1;		// converting to indexes
		v=v-1;
		if(hole[bone_pos]==1)
			flag=1;
		if( ((u==bone_pos)||(v==bone_pos)) && (flag==0) )
		{
			bone_pos=u+v-bone_pos;
		}
		num_swaps++;
		if((k==300000)&&(k-num_swaps<10))
			printf("u and v are %d %d\n",u+1,v+1);
	}
	printf("%d\n",bone_pos+1);
	return 0;
}


#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
int cmp(const void *a, const void *b)
{
	return ( *(int*)a - *(int*)b );
}
int min(int a,int b)
{
	if(a<=b)
		return a;
	else
		return b;
}
int max(int a,int b)
{
	if(a>=b)
		return a;
	else
		return b;
}
int main()
{
	int n,m,k,i,u,v,temp,num_swaps,bone_pos,flag,hole[1000005];
	scanf("%d %d %d",&n,&m,&k);		// number of cups, holes, swaps
	for(i=0;i<m;i++)
	{
		scanf("%d",&temp);
		hole[temp-1]=1;			// 0 indexed
	}
	num_swaps=0;
	bone_pos=0;		// at index 0 initially
	flag=0;			// bone can move
	while(num_swaps<k)
	{
		scanf("%d %d",&u,&v);
		u=u-1;		// converting to indexes
		v=v-1;
		if(hole[bone_pos]==1)
			flag=1;
		if( ((u==bone_pos)||(v==bone_pos)) && (flag==0) )
		{
			if(bone_pos==u)
				bone_pos=v;
			else
				bone_pos=u;
		}
		num_swaps++;
	}
	//printf("flag is %d\n",flag);
	printf("%d\n",bone_pos+1);
	return 0;
}


#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
int cmp(const void *a, const void *b)
{
	return ( *(int*)a - *(int*)b );
}
int min(int a,int b)
{
	if(a<=b)
		return a;
	else
		return b;
}
int max(int a,int b)
{
	if(a>=b)
		return a;
	else
		return b;
}
int hole[1000005];
int main()
{
	int n,m,k,i,u,v,temp,num_swaps,bone_pos,flag;
	scanf("%d %d %d",&n,&m,&k);		// number of cups, holes, swaps
	for(i=0;i<=m;i++)
		hole[i]=0;
	for(i=0;i<m;i++)
	{
		scanf("%d",&temp);
		if(k==300000)
		{
			if(temp==999819)
			{
				printf(" Hole given at 999819\n");
				break;
			}
		}
		hole[temp-1]=1;			// 0 indexed
	}
	num_swaps=0;
	bone_pos=0;		// at index 0 initially
	flag=0;			// bone can move
	if(k==300000)
	{
		printf("Hole value at 999819 is %d\n",hole[999818]);
	}
	while(num_swaps<k)
	{
		scanf("%d %d",&u,&v);
		u=u-1;		// converting to indexes
		v=v-1;
		if(hole[bone_pos]==1)
		{
			flag=1;
			if(k==300000)
			{
				printf("Hole at bone_pos %d\n",bone_pos);
				break;
			}
		}
		if( ((u==bone_pos)||(v==bone_pos)) && (flag==0) )
		{
			bone_pos=u+v-bone_pos;
		}
		num_swaps++;
		if((k==300000)&&(k-num_swaps<10))
			printf("u and v are %d %d\n",u+1,v+1);
	}
	printf("%d\n",bone_pos+1);
	return 0;
}


#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
int cmp(const void *a, const void *b)
{
	return ( *(int*)a - *(int*)b );
}
int min(int a,int b)
{
	if(a<=b)
		return a;
	else
		return b;
}
int max(int a,int b)
{
	if(a>=b)
		return a;
	else
		return b;
}
int main()
{
	int n,m,k,i,u,v,temp,num_swaps,bone_pos,flag,hole[1000005];
	scanf("%d %d %d",&n,&m,&k);		// number of cups, holes, swaps
	for(i=0;i<=m;i++)
		hole[i]=0;
	for(i=0;i<m;i++)
	{
		scanf("%d",&temp);
		hole[temp-1]=1;			// 0 indexed
	}
	num_swaps=0;
	bone_pos=0;		// at index 0 initially
	flag=0;			// bone can move
	while(num_swaps<k)
	{
		scanf("%d %d",&u,&v);
		u=u-1;		// converting to indexes
		v=v-1;
		if(hole[bone_pos]==1)
			flag=1;
		if( ((u==bone_pos)||(v==bone_pos)) && (flag==0) )
		{
			bone_pos=u+v-bone_pos;
		}
		num_swaps++;
		if((k==300000)&&(k-num_swaps<35))
			printf("u and v are %d %d",u,v);
	}
	printf("%d\n",bone_pos+1);
	return 0;
}


#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
int cmp(const void *a, const void *b)
{
	return ( *(int*)a - *(int*)b );
}
int min(int a,int b)
{
	if(a<=b)
		return a;
	else
		return b;
}
int max(int a,int b)
{
	if(a>=b)
		return a;
	else
		return b;
}
int main()
{
	int n,m,k,i,u,v,temp,num_swaps,bone_pos,flag,hole[1000005];
	scanf("%d %d %d",&n,&m,&k);		// number of cups, holes, swaps
	for(i=0;i<=m;i++)
		hole[i]=0;
	for(i=0;i<m;i++)
	{
		scanf("%d",&temp);
		if(k==300000)
		{
			if(temp==999819)
			{
				printf(" Hole given at 999819\n");
				break;
			}
		}
		hole[temp-1]=1;			// 0 indexed
	}
	num_swaps=0;
	bone_pos=0;		// at index 0 initially
	flag=0;			// bone can move
	while(num_swaps<k)
	{
		scanf("%d %d",&u,&v);
		u=u-1;		// converting to indexes
		v=v-1;
		if(hole[bone_pos]==1)
		{
			flag=1;
			if(k==300000)
			{
				printf("Hole at bone_pos %d\n",bone_pos);
				break;
			}
		}
		if( ((u==bone_pos)||(v==bone_pos)) && (flag==0) )
		{
			bone_pos=u+v-bone_pos;
		}
		num_swaps++;
		if((k==300000)&&(k-num_swaps<10))
			printf("u and v are %d %d\n",u+1,v+1);
	}
	printf("%d\n",bone_pos+1);
	return 0;
}


#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
int cmp(const void *a, const void *b)
{
	return ( *(int*)a - *(int*)b );
}
int min(int a,int b)
{
	if(a<=b)
		return a;
	else
		return b;
}
int max(int a,int b)
{
	if(a>=b)
		return a;
	else
		return b;
}
int hole[1000005];
int main()
{
	int n,m,k,i,u,v,temp,num_swaps,bone_pos,flag;
	scanf("%d %d %d",&n,&m,&k);		// number of cups, holes, swaps
	for(i=0;i<m;i++)
	{
		scanf("%d",&temp);
		hole[temp-1]=1;			// 0 indexed
	}
	num_swaps=0;
	bone_pos=0;		// at index 0 initially
	flag=0;			// bone can move
	while(num_swaps<k)
	{
		scanf("%d %d",&u,&v);
		u=u-1;		// converting to indexes
		v=v-1;
		if(hole[bone_pos]==1)
			flag=1;
		if( ((u==bone_pos)||(v==bone_pos)) && (flag==0) )
		{
			bone_pos=u+v-bone_pos;
		}
		num_swaps++;
	}
	printf("%d\n",bone_pos+1);
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int a, b, c, k, o, m, n, l;
  cin >> k;
  cin >> l;
  cin >> m;
  cin >> n;
  o = (k+l+m+n)/3;
  if (k==o) {
    a = o-l;
    b = o-m;
    c = o-n;
  } else {
    a = o-k;
    if (l==o) {
      b = o-m;
      c = o-n;
    } else {
      b = o-l;
      if (m==o) {
        c = o-n;
      } else {
        c = o-m;
      }
    }
  }
  cout << b << endl;
  cout << a << endl;
  cout << c << endl;
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int a, b, c, k, l, m, n, o, p;
  cin >> k;
  cin >> l;
  cin >> m;
  cin >> n;
  o = (k+l+m+n)/3;
  if (0==o-k) {
    k = 0;
  } else {
    if (0==o-l) {
      l = 0;
    } else {
      if (0==o-m) {
        m = 0;
      } else {
        n = 0;
      }
    }
  }
  if (k==0) {
    a = o-l;
    b = o-m;
    c = o-n;
  } else {
    a = o-k;
    if (l==0) {
      b = o-m;
      c = o-n;
    } else {
      b = o-l;
      if (m==0) {
        c = o-n;
      } else {
        c = o-m;
      }
    }
  }
  cout << a << endl;
  cout << b << endl;
  cout << c << endl;
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int a, b, c, k, l, m, n, o, p;
  cin >> k;
  cin >> l;
  cin >> m;
  cin >> n;
  o = (k+l+m+n)/3;
  if (k==o) {
    a = o-l;
    b = o-m;
    c = o-n;
  } else {
    a = o-k;
    if (l==o) {
      b = o-m;
      c = o-n;
    } else {
      b = o-l;
      if (m==o) {
        c = o-n;
      } else {
        c = o-m;
      }
    }
  }
  cout << a << endl;
  cout << b << endl;
  cout << c << endl;
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int a, b, c, k, l, m, n;
  float o;
  cin >> k;
  cin >> l;
  cin >> m;
  cin >> n;
  o = k/3+l/3+m/3+n/3;
  if (k==o) {
    a = o-l;
    b = o-m;
    c = o-n;
  } else {
    a = o-k;
    if (l==o) {
      b = o-m;
      c = o-n;
    } else {
      b = o-l;
      if (m==o) {
        c = o-n;
      } else {
        c = o-m;
      }
    }
  }
  cout << b << endl;
  cout << a << endl;
  cout << c << endl;
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int a, b, c, k, l, m, o, n;
  cin >> k;
  cin >> l;
  cin >> m;
  cin >> n;
  o = (k+l+m+n)/3;
  if (k==o) {
    a = o-l;
    b = o-m;
    c = o-n;
  } else {
    a = o-k;
    if (l==o) {
      b = o-m;
      c = o-n;
    } else {
      b = o-l;
      if (m==o) {
        c = o-n;
      } else {
        c = o-m;
      }
    }
  }
  cout << b << endl;
  cout << a << endl;
  cout << c << endl;
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	long long a, b, c, k, o, m, n, l;
  cin >> k;
  cin >> l;
  cin >> m;
  cin >> n;
  o = (k+l+m+n)/3;
  if (k==o) {
    a = o-l;
    b = o-m;
    c = o-n;
  } else {
    a = o-k;
    if (l==o) {
      b = o-m;
      c = o-n;
    } else {
      b = o-l;
      if (m==o) {
        c = o-n;
      } else {
        c = o-m;
      }
    }
  }
  cout << b << endl;
  cout << a << endl;
  cout << c << endl;
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	float a, b, c, k, l, m, n, o;
  cin >> k;
  cin >> l;
  cin >> m;
  cin >> n;
  o = (k+l+m+n)/3;
  if (k==o) {
    a = o-l;
    b = o-m;
    c = o-n;
  } else {
    a = o-k;
    if (l==o) {
      b = o-m;
      c = o-n;
    } else {
      b = o-l;
      if (m==o) {
        c = o-n;
      } else {
        c = o-m;
      }
    }
  }
  cout << b << endl;
  cout << a << endl;
  cout << c << endl;
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int a, b, c, k, l, m, n, o, p;
  cin >> k;
  cin >> l;
  cin >> m;
  cin >> n;
  o = (k+l+m+n)/3;
  if (k==o) {
    a = o-l;
    b = o-m;
    c = o-n;
  } else {
    a = o-k;
    if (l==o) {
      b = o-m;
      c = o-n;
    } else {
      b = o-l;
      if (m==o) {
        c = o-n;
      } else {
        c = o-m;
      }
    }
  }
  cout << b << endl;
  cout << a << endl;
  cout << c << endl;
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int a, b, c, k, l, m, n;
  float o;
  cin >> k;
  cin >> l;
  cin >> m;
  cin >> n;
  o = (k+l+m+n)/3;
  if (k==o) {
    a = o-l;
    b = o-m;
    c = o-n;
  } else {
    a = o-k;
    if (l==o) {
      b = o-m;
      c = o-n;
    } else {
      b = o-l;
      if (m==o) {
        c = o-n;
      } else {
        c = o-m;
      }
    }
  }
  cout << b << endl;
  cout << a << endl;
  cout << c << endl;
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	float a, b, c, k, l, m, n, o;
  cin >> k;
  cin >> l;
  cin >> m;
  cin >> n;
  o = (k/3)+(l/3)+(m/3)+(n/3);
  if (k==o) {
    a = o-l;
    b = o-m;
    c = o-n;
  } else {
    a = o-k;
    if (l==o) {
      b = o-m;
      c = o-n;
    } else {
      b = o-l;
      if (m==o) {
        c = o-n;
      } else {
        c = o-m;
      }
    }
  }
  cout << b << endl;
  cout << a << endl;
  cout << c << endl;
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	float a, b, c, k, l, m, o, n;
  cin >> k;
  cin >> l;
  cin >> m;
  cin >> n;
  o = (k/3)+(l/3)+(m/3)+(n/3);
  if (k==o) {
    a = o-l;
    b = o-m;
    c = o-n;
  } else {
    a = o-k;
    if (l==o) {
      b = o-m;
      c = o-n;
    } else {
      b = o-l;
      if (m==o) {
        c = o-n;
      } else {
        c = o-m;
      }
    }
  }
  cout << b << endl;
  cout << a << endl;
  cout << c << endl;
	return 0;
}


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

int main()
{
    int x[5],a,b,c,mm=0;
    for(int i=1;i<=4;i++)
    {
        cin>>x[i];
    }
    for(int i=1;i<=4;i++)
    {
        mm=max(mm,x[i]);
    }
    if(mm%2==0)
    {
        a=2;
        b=mm/2;
        c=mm-a-b;
    }
    else
    {
        a=1;
        b=(mm-1)/2;
        c=mm-b-a;
    }
    cout <<a<<" "<<b<<" "<<c;

}


#include <iostream>
using namespace std;
int main()
{
    int a=0,b=0,c=0,aa=0,bb=0,cc=0,aaa=0,bbb=0,ccc=0,aaaa=0,bbbb=0,cccc=0,x1,x2,x3,x4;
    cin>>x1>>x2>>x3>>x4;
    a=(x1-x4+x2)/2;
    c=x2-a;
    b=x4-c;
    if(a+b+c==x3)
    {
        cout <<a<<" "<<b<<" "<<c;
        return 0;
    }
    aa=(x2-x3+x1)/2;
    cc=x1-a;
    bb=x3-c;
    if(aa+bb+cc==x4)
    {
        cout <<aa<<" "<<bb<<" "<<cc;
        return 0;
    }
    aaa=(x3-x1+x4)/2;
    ccc=x4-a;
    bbb=x3-c;
    if(aaa+bbb+ccc==x2)
    {
        cout <<aaa<<" "<<bbb<<" "<<ccc;
        return 0;
    }
    aaaa=(x4-x2+x3)/2;
    cccc=x3-a;
    bbbb=x2-c;
    if(aaaa+bbbb+cccc==x1)
    {
        cout <<aaaa<<" "<<bbbb<<" "<<cccc;
        return 0;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main() {
    int x1, x2, x3, x4, a, b, c;
    cin >> x1 >> x2 >> x3 >> x4;
    a = x4 - x3;
    b = x4 - x2;
    c = x4 - x1;
    cout << a << " " << b << " " << c;
    return 0;
}


#include <iostream>

using namespace std;

int main() {
    int x1, x2, x3, x4, a, b, c;
    cin >> x1 >> x2 >> x3 >> x4;
    a = (x2 + x1 - x3) / 2;
    b = x1 - a;
    c = x3 - b;
    cout << a << " " << b << " " << c;
    return 0;
}


#include <iostream>

using namespace std;

int main() {
    int x1, x2, x3, x4, a, b, c;
    cin >> x1 >> x2 >> x3 >> x4;
    a = (x3 + x1 - x2) / 2;
    b = x1 - a;
    c = x2 - b;
    cout << a << " " << b << " " << c;
    return 0;
}


#include <iostream>

using namespace std;
int main ()
{
 int a,b,c,d,x,y,z;
cin>>a>>b>>c>>d;
    x=d-c;
    y=d-b;
    z=d-a;
    cout<<x<<y<<z<<endl;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    long long int a,b,c,d,x,y,z;
    cin>>a>>b>>c>>d;
    if(b>a && b>c && b>d) {
        x=b-d;
        y=b-c;
        z=b-a;
    }
    else if(a>b && a>c && a>d) {
        x=a-d;
        y=a-b;
        z=a-c;
    }

    else if(c>a && c>b && c>d) {
        x=c-a;
        y=c-b;
        z=c-d;
    }
    else if(d>a && d>b && d>c) {
        x=d-a;
        y=d-b;
        z=d-c;
    }
    cout<<x<< " "<<y<< " "<<z<<endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    long long int a,b,c,d,x,y,z;
    cin>>a>>b>>c>>d;
    if(b>a && b>c && b>d) {
        x=b-d;
        y=b-c;
        z=b-a;
    }
    else if(a>b && a>c && a>d) {
        x=a-d;
        y=a-b;
        z=a-c;
    }

    else if(c>a && c>b && c>d) {
        x=c-a;
        y=c-b;
        z=c-d;
    }
    else if(d>a && d>b && d>c) {
        x=d-a;
        y=d-b;
        z=d-c;
    }
    cout<<z<< " "<<y<< " "<<x<<endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main ()
{
 long long int a,b,c,d,x,y,z;
cin>>a>>b>>c>>d;
    x=d-c;
    y=d-b;
    z=d-a;
    cout<<abs(x)<<" "<<abs(y)<<" "<<abs(z)<<endl;
}


#include <iostream>

using namespace std;
int main ()
{
 int a,b,c,d,x,y,z;
cin>>a>>b>>c>>d;
    x=d-c;
    y=d-b;
    z=d-a;
    cout<<x<<" "<<y<<" "<<z<<endl;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    long long int a,b,c,d,x,y,z;
    cin>>a>>b>>c>>d;
    if(b>d) {
        x=b-d;
    }
    if(b>c) {
        y=b-c;
    }
    if(b>a) {
        z=b-a;
    }
    if(a==b && b==c) {
        x=d-a;
        y=d-b;
        z=d-c;
    }
    if(a>d) {
        x=a-d;
    }
    if(a>b) {
        y=a-b;
    }
    if(a>c) {
        z=a-c;
    }

    cout<<x<< " "<<y<< " "<<z;
}


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

int main()
{
int a,b,c;
vektor<int> v;

for(i=0;i<4;i++)
{
int x;
cin>>x;
v.push_back(x);
}
sort(v.begin(),v.end())
a=v[0]+v[1]-v[2]/2;
b=v[0]+v[2]-v[1]/2;
c=v[1]+v[2]-v[0]/2;

cout<<a<<b<<c;

return 0;
}


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

int main()
{
vector<int>v;
int a,b,c,i;

for(i=0;i<4;i++)
{
int x;
cin>>x;
v.push_back(x);
}
sort(v.begin(),v.end());
a=v[0]+v[1]-v[2]/2;
b=v[0]+v[2]-v[1]/2;
c=v[1]+v[2]-v[0]/2;

cout<<a<<b<<c;

return 0;
}


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

vector<int>v;
int x,y;
int main()
{

for(int i=0;i<4;i++)
{
cin>>x;
v.push_back(x);
}
sort(v.begin(),v.end());
for(int i=0;i<3;i++);
{
y=v[3]-v[i];
cout<<y<<" ";
}

return 0;
}


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

vector<int>v;
int i,x,y;
int main()
{

for(i=0;i<4;i++)
{
cin>>x;
v.push_back(x);
}
sort(v.begin(),v.end());
for(i=0;i<3;i++);
{
y=v[3]-v[i];
cout<<y<<" ";
}

return 0;
}


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

int main()
{
vector<int>v;
int a,b,c,i;

for(i=0;i<4;i++)
{
int x;
cin>>x;
v.push_back(x);
}
sort(v.begin(),v.end());
a=v[0]+v[1]-v[2]/2;
b=v[2]+v[0]-v[1]/2;
c=v[1]+v[2]-v[0]/2;

cout<<a<<b<<c;

return 0;
}


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

int main()
{
vector<int>v;
int a,b,c;

for(i=0;i<4;i++)
{
int x;
cin>>x;
v.push_back(x);
}
sort(v.begin(),v.end())
a=v[0]+v[1]-v[2]/2;
b=v[0]+v[2]-v[1]/2;
c=v[1]+v[2]-v[0]/2;

cout<<a<<b<<c;

return 0;
}


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

vector<int>v;
int i,x,y;
int main()
{

for(int i=0;i<4;i++)
{
cin>>x;
v.push_back(x);
}
sort(v.begin(),v.end());
for(int i=0;i<3;i++);
{
y=v[3]-v[i];
cout<<y<<" ";
}

return 0;
}


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

int main()
{
vector<int>v;
int i,x,y;

for(i=0;i<4;i++)
{
int x;
cin>>x;
v.push_back(x);
}
sort(v.begin(),v.end());
for(i=0;i<0;i++);
{
y=v[3]-v[i];
cout<<y<<" ";
}

return 0;
}


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

vector<int> v;
int x,y;

int main()
{
for(int i=0; i<4; i++)
{
cin>>x;
v.push_back(x);
}
sort(v.begin(), v.end() );
for(int i=0; i<3; i++) {
y=v[3]-v[i];
cout<<y<<" ";
}

return 0;
}


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

int main()
{
vektor<int>v;
int a,b,c;

for(i=0;i<4;i++)
{
int x;
cin>>x;
v.push_back(x);
}
sort(v.begin(),v.end())
a=v[0]+v[1]-v[2]/2;
b=v[0]+v[2]-v[1]/2;
c=v[1]+v[2]-v[0]/2;

cout<<a<<b<<c;

return 0;
}


#include <stdio.h>

int main(){
    int arr[4],max = 0,j;
    for(int i = 0;i < 4;i++){
        scanf("%d ",arr[i]);
        if(max < arr[i]){
            j = i;max = arr[i];
        }
    }
    for(int i = 0;i < 4;i++){
        if(j != i)
            printf("%d ",max - arr[i]);
    }
    return 0;
}


#include <stdio.h>

int main(){
    int arr[4],max = 0,j;
    for(int i = 0;i < 4;i++){
        scanf("%d ",arr[i]);
        if(max < arr[i]){
            max = arr[i];
        }
    }
    for(int i = 0;i < 4;i++){
        if(max != arr[i])
            printf("%d ",max - arr[i]);
    }
    return 0;
}


#include <stdio.h>

int main(){
    int arr[4],max = 0,j;
    for(int i = 0; < 4;i++){
        scanf("%d ",arr[i]);
        if(max < arr[i]){
            j = i;max = arr[i];
        }
    }
    for(int i = 0;i < 4;i++){
        if(j != i){
            printf("%d ",max - arr[i]);
        }
    }
    return 0;
}


#include <stdio.h>

int main(){
    int x,y,z,w,max = 0,i;
	scanf("%d %d %d %d",&x,&y,&z,&w);
    max = x > y?x : y;
    max = max > z?max : z;
    max = max > w?max : w;
	if(max != x)
	printf("%d ",max - x);
	if(max != y)
	printf("%d ",max - y);
	if(max != z)
	printf("%d ",max - z);
	if(max != w)
	printf("%d ",max - w);
    return 0;
}


#include <stdio.h>

int main(){
    int arr[4],max = 0,j;
    for(int i = 0;i < 4;i++){
        scanf("%d",arr[i]);
        if(max < arr[i]){
            max = arr[i];
        }
    }
    for(int i = 0;i < 4;i++){
        if(max != arr[i])
            printf("%d ",max - arr[i]);
    }
    return 0;
}


#include <stdio.h>

int main(){
    int arr[4],max = 0,i;
    for(i = 0;i < 4;i++){
        scanf("%d",arr[i]);
        if(max < arr[i]){
            max = arr[i];
        }
    }
    for(i = 0;i < 4;i++){
        if(max != arr[i])
            printf("%d ",max - arr[i]);
    }
    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void)
{
  vector <int> v;
  unsigned int sum = 0,i=0,avarage,a;
  while(i < 4)
    {
      cin >> a ;
      v.push_back(a);
      sum += a;

      i++;
    }
  avarage = int(sum / 3);
  sort(v.rbegin(),v.rend());
  for(i=0 ; i<4; i++)
    {
      a = avarage - v[i];
      if(a >0)
        cout << int(a) << endl;
    }

}


#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void)
{
  vector <int> v;
  int sum = 0,i=0,avarage,a;
  while(i < 4)
    {
      cin >> a ;
      v.push_back(a);
      sum += a;

      i++;
    }
  avarage = int(sum / 3);
  sort(v.begin(),v.end());
  for(i=0 ; i<4; i++)
    {
      a = avarage - v[i];
      if(a >0)
        cout << a;
    }

}


#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void)
{
  vector <int> v;
  int sum = 0,i=0,avarage,a;
  while(i < 4)
    {
      cin >> a ;
      v.push_back(a);
      sum += a;

      i++;
    }
  avarage = int(sum / 3);
  sort(v.rbegin(),v.rend());
  for(i=0 ; i<4; i++)
    {
      a = avarage - v[i];
      if(a >0)
        cout << int(a) << endl;
    }

}


#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void)
{
  vector <int> v;
  long sum = 0,i=0,avarage,a;
  while(i < 4)
    {
      cin >> a ;
      v.push_back(a);
      sum += a;

      i++;
    }
  avarage = long(sum / 3);
  sort(v.rbegin(),v.rend());
  for(i=0 ; i<4; i++)
    {
      a = avarage - v[i];
      if(a >0)
        cout << long(a) << endl;
    }

}


#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void)
{
  vector <int> v;
  int sum = 0,i=0,avarage,a;
  while(i < 4)
    {
      cin >> a ;
      v.push_back(a);
      sum += a;

      i++;
    }
  avarage = sum / 3;
  sort(v.begin(),v.end());
  for(i=0 ; i<4; i++)
    {

      if(avarage - v[i] >0)
        cout << avarage - v[i] ;
    }

}


#include<iostream>
#include<stdlib>
#include<vector>

using namespace std;

int main(void)
{
  vector <int> v;
  int sum = 0,i=0,avarage,a;
  while(i < 4)
    {
      cin >> a ;
      v.push_back(a);
      sum += a;

      i++;
    }
  avarage = sum / 3;
  for(i=0 ; i<4; i++)
    {

      if(avarage - v[i] >0)
        cout << avarage - v[i] ;
    }

}


#include<iostream>
#include<vector>

using namespace std;

int main(void)
{
  vector <int> v;
  int sum = 0,i=0,avarage,a;
  while(i < 4)
    {
      cin >> a ;
      v.push_back(a);
      sum += a;

      i++;
    }
  avarage = sum / 3;
  sort(v.begin(),v.end());
  for(i=0 ; i<4; i++)
    {

      if(avarage - v[i] >0)
        cout << avarage - v[i] ;
    }

}


#include<iostream>
#include<vector>

using namespace std;

int main(void)
{
  vector <int> v;
  int sum = 0,i=0,avarage,a;
  while(i < 4)
    {
      cin >> a ;
      v.push_back(a);
      sum += a;

      i++;
    }
  avarage = sum / 3;
  for(i=0 ; i<4; i++)
    {

      if(avarage - v[i] >0)
        cout << avarage - v[i] ;
    }

}


#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void)
{
  vector <int> v;
  int sum = 0,i=0,avarage,a;
  while(i < 4)
    {
      cin >> a ;
      v.push_back(a);
      sum += a;

      i++;
    }
  avarage = int(sum / 3);
  sort(v.rbegin(),v.rend());
  for(i=0 ; i<4; i++)
    {
      a = avarage - v[i];
      if(a >0)
        cout << a << endl;
    }

}


#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void)
{
  vector <int> v;
  long sum = 0,i=0,avarage,a;
  while(i < 4)
    {
      cin >> a ;
      v.push_back(a);
      sum += a;

      i++;
    }
  avarage = int(sum / 3);
  sort(v.rbegin(),v.rend());
  for(i=0 ; i<4; i++)
    {
      a = avarage - v[i];
      if(a >0)
        cout << int(a) << endl;
    }

}


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

int main(void)
{
    vector<int> v;
    for(int x=0;x<4;x++)
    {
        int a;
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    int m=v.at(v.size());
    for(int i=0;i<v.size();i++)
    {
        if((m-v[i])>0)
        {
            cout<<m-v[i]<<" ";
        }
    }
}


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

int main(void)
{
    vector<int> v;
    for (int i=0;i<4;i++)
    {
        int a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    for (int i=0;i<4;i++)
    {
        cout<<v.at(4)-v.at(1)<<" "<<v.at(4)-v.at(2)<<" "<<v.at(4)-v.at(3);
    }
}


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

int main(void)
{
    vector<int> v;
    for (int i=0;i<4;i++)
    {
        int a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    for (int i=0;i<4;i++)
    {
        cout<<v.at(4)-v.at(1)<<" "<<v.at(4)-v.at(2)<<" "<<v.at(4)-v.at(3);
    }
}


#include<bits\stdc++.h>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define lower(x) transform(x.begin(), x.end(),x.begin(),::tolower)
#define upper(x) transform(x.begin(), x.end(),x.begin(),::toupper)
#define max(x) *max_element(x.begin(), x.end())
#define min(x) *min_element(x.begin(), x.end())
#define rev(x) reverse(x.begin(), x.end())
int main()
{
    std::vector<int> v;
    for(int x=0;x<4;x++)
    {
        ll a;
        cin>>a;
        v.pb(a);
    }
    ll m=max(v);
    for(ll i=0;i<v.size();i++)
    {
        if((m-v[i])>0)
        {
            cout<<m-v[i]<<" ";
        }
    }
}


#include <iostream>
using namespace std;
int main() {
    vector <int> a(4);
    for (int i = 0; i < 4; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < 4; i++)
    {
        cout << a[4] - a[i] << " ";
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    vector <int> a(4);
    for (int i = 0; i < 4; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < 4; i++)
    {
        cout << a[4] - a[i] << " ";
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    vector <int> a(4);
    for (int i = 0; i < 4; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < 3; i++)
    {
        cout << a[3] - a[i] << " ";
    }
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int main() {
    vector <int> a(4);
    for (int i = 0; i < 4; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < 4; i++)
    {
        cout << a[4] - a[i] << " ";
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>

using namespace std;
int main()
{
    int ans = 0;
    vector<int> num;
    int a;
    int total=0;
    for(int i=0; i<4;i++){
        cin>>a;
        total+=a;
        num.push_back(a);
    }
    sort(num.begin(),num.end());
    int d=total/3;
    cout << d-num.at(0)<<" "<<d-num.at(1)<<" "<<d-num.at(2) << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <list>
#include <map>
#include <stack>
#include <string>
#include <vector>
#include <set>
using namespace std;

int main()
{
    int n;
    cin >> n;
    set<int> num;
    int temp;

    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        num.insert(temp);
    }
    vector<int> ans(num.begin(), num.end());
    if (num.size() >= 4)
    {
        cout << -1 << endl;
        return 0;
    }
    if(num.size()==1){
        cout << 0 << endl;
        return 0;
    }
    if (num.size() == 2)
    {
        if ((ans.at(1) + ans.at(0)) % 2 == 0)
        {
            cout << (ans.at(1) - ans.at(0))/2 << endl;
            return 0;
        }
        else{
            cout << (ans.at(1) - ans.at(0)) << endl;
        return 0;
        }
    }

    if (num.size() == 3)
    {

        if (ans.at(2) - ans.at(1) == ans.at(1) - ans.at(0))
        {
            cout << (ans.at(1) - ans.at(0)) << endl;
            return 0;
        }
        else
        {
            cout << -1 << endl;
            return 0;
        }
    }
}


#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>

using namespace std;
int main()
{
    int ans = 0;
    vector<int> num;
    int total=0;
    for(int i=0; i<4;i++){
        int a;
        cin>>a;
        total+=a;
        num.push_back(a);
    }
    sort(num.begin(),num.end());
    int d=total/3;
    cout << d-num.at(0)<<" "<<d-num.at(1)<<" "<<d-num.at(2) << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>

using namespace std;
int main()
{
    long ans = 0;
    vector<long> num;
    long total=0;
    for(int i=0; i<4;i++){
        long a;
        cin>>a;
        total+=a;
        num.push_back(a);
    }
    sort(num.begin(),num.end());
    long d=total/3;
    cout << d-num.at(0)<<" "<<d-num.at(1)<<" "<<d-num.at(2) << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
typedef long long ll;
using namespace std;
int main()
{
    ll ans = 0;
    vector<long> num;
    ll total=0;
    for(int i=0; i<4;i++){
        ll a;
        cin>>a;
        total+=a;
        num.push_back(a);
    }
    sort(num.begin(),num.end());
    ll d=total/3;
    cout << d-num.at(0)<<" "<<d-num.at(1)<<" "<<d-num.at(2) << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
int m=1000000007;
int a1,b1,c1,d1;
cin>>a1;
a1=(a+b)%m;
cin>>b1;
b1=(a+c)%m;
cin>>c1;
c1=(b+c)%m;
cin>>d1;
d1=(a+b+c)%m;
cout<<a<<" "<<b<<" "<<c<<endl;
return 0;

}


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

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    VI a(4);
    REP(i,4) cin >> a[i];
    sort(ALL(a));
    REP(i,3) cout << a[3] - a[i] << " ";
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
const unsigned int m=1000000007;
long long a1,b1,c1,d1;
cin>>a1;
//a1=(a+b);//%m;
cin>>b1;
//b1=(a+c);//%m;
cin>>c1;
//c1=(b+c);//%m;
cin>>d1;
//d1=(a+b+c);//%m;
long long res1, res2 ,res3;
res1=(d1-a1)%m;
res2=(d1-c1)%m;
res3= (res2+a1)%m;
cout<<res1<<" "<<res2<<" "<<res3<<endl;
return 0;

}


#include <bits/stdc++.h>
using namespace std;
int main(){
long long a,b,c;
const unsigned int m=1000000007;
long long a1,b1,c1,d1;
cin>>a1;
//a1=(a+b);//%m;
cin>>b1;
//b1=(a+c);//%m;
cin>>c1;
//c1=(b+c);//%m;
cin>>d1;
//d1=(a+b+c);//%m;
long long res1, res2 ,res3;
res1=(d1-a1)%m;
res2=(d1-c1)%m;
res3= (res2+a1)%m;
cout<<res1<<" "<<res2<<" "<<res3<<endl;
return 0;

}


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

int main()
{
	 ios_base::sync_with_stdio(false);
     cin.tie(NULL);

  int t,c=0,i,j,p,x,y,osum,nsum=0,m,v;
 	int n=3;
 	int a[n];
 	for(i=0;i<=n;i++)
 	{
 		cin>>a[i];
	 }
	 sort(a+0,a+4);

	 cout<<a[3]-a[2]<<" ";
	 cout<<a[3]-a[1]<<" ";
	 cout<<a[3]-a[0];
return 0;
}


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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> pll;
typedef vector<long long int> vl;
#define all(c) c.begin(), c.end()
#define pb push_back
#define mp make_pair
vector<int> vi;

int main()
{
	 ios_base::sync_with_stdio(false);
     cin.tie(NULL);

  ll t,c=0,i,j,p,x,y,osum,nsum=0,m,v;
 	ll n;
 	ll a[3];
 	for(i=0;i<4;i++)
 	{
 		cin>>a[i];
	 }
	 sort(a+0,a+4);

	 cout<<a[3]-a[2]<<" ";
	 cout<<a[3]-a[1]<<" ";
	 cout<<a[3]-a[0];
return 0;
}


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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> pll;
typedef vector<long long int> vl;
#define all(c) c.begin(), c.end()
#define pb push_back
#define mp make_pair
vector<int> vi;

int main()
{
	 ios_base::sync_with_stdio(false);
     cin.tie(NULL);

  int t,c=0,i,j,p,x,y,osum,nsum=0,m,v;
 	int n;
 	int a[3];
 	for(i=0;i<4;i++)
 	{
 		cin>>a[i];
	 }
	 sort(a+0,a+4);

	 cout<<a[3]-a[2]<<" ";
	 cout<<a[3]-a[1]<<" ";
	 cout<<a[3]-a[0];
return 0;
}


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

int main()
{
vector<int> a(4);
	for (int i = 0; i < 4; ++i) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	cout << a[3] - a[0] << " " << a[3] - a[1] << " " << a[3] - a[2] << endl;

	return 0;
return 0;
}


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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> pll;
typedef vector<long long int> vl;
#define all(c) c.begin(), c.end()
#define pb push_back
#define mp make_pair
vector<int> vi;

int main()
{
	 ios_base::sync_with_stdio(false);
     cin.tie(NULL);

  ll t,c=0,i,j,p,x,y,osum,nsum=0,m,v;
 	ll n;
 	ll a[3];
 	for(i=0;i<4;i++)
 	{
 		cin>>a[i];
	 }
	 sort(a+0,a+4);

	 cout<<a[3]-a[2]<<endl;
	 cout<<a[3]-a[1]<<endl;
	 cout<<a[3]-a[0]<<endl;
return 0;
}


#include<iostream>
using namespace std;
int main(){

int n1,n2,n3,n4;
cin>>n1>>n2>>n3>>n4;

int b=abs(n2-n3+n1)/2;
int c=abs(n3-n1+n2)/2;
int a=abs(n1-n2+n3)/2;

cout<<a<<" "<<b<<" "<<c-1;

return 0;
}


#include<iostream>
using namespace std;
int main(){

int n1,n2,n3,n4;
cin>>n1>>n2>>n3>>n4;

int b=abs(n2-n3+n1)/2;
int c=abs(n3-n1+n2)/2;
int a=abs(n1-n2+n3)/2;

cout<<a<<" "<<b<<" "<<c+1;

return 0;
}


#include<iostream>
using namespace std;
int main(){

int n1,n2,n3,n4;
cin>>n1>>n2>>n3>>n4;

cout<<n4-n1<<" "<<n4-n2<<" "<<n4-n3;

return 0;
}

/*
user >> heguangfu, contest: Codeforces Round #552 (Div. 3), problem: (A) Restoring Three Numbers, Accepted, #, Copy
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define INF 0x3f3f3f3f;
#define fi first
#define se second
#define MP make_pair
#define PI pair<int,int>
#define lson l,m,rt<<1,ls,rs
#define rson m+1,r,rt<<1|1,ls,rs
#define test printf("here!!!\n")
using namespace std;
const int mx=2000+10;
int n,m;
ll a[5];
int main()
{
    scanf("%lld%lld%lld%lld",&a[0],&a[1],&a[2],&a[3]);
    sort(a,a+4);
    printf("%lld %lld %lld\n",a[3]-a[0],a[3]-a[1],a[3]-a[2]);
}
*/


#include<iostream>
using namespace std;
int main(){

int n1,n2,n3,n4;
cin>>n1>>n2>>n3>>n4;

int max=n4;
if(n1>max){
    n4=n1;
    n1=max;
}
else if(n2>max){
    n4=n2;
    n2=max;
}
else if(n3>max){
    n4=n3;
    n3=max;
}

cout<<n4-n1<<" "<<n4-n2<<" "<<n4-n3;

return 0;
}

/*
user >> heguangfu, contest: Codeforces Round #552 (Div. 3), problem: (A) Restoring Three Numbers, Accepted, #, Copy
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define INF 0x3f3f3f3f;
#define fi first
#define se second
#define MP make_pair
#define PI pair<int,int>
#define lson l,m,rt<<1,ls,rs
#define rson m+1,r,rt<<1|1,ls,rs
#define test printf("here!!!\n")
using namespace std;
const int mx=2000+10;
int n,m;
ll a[5];
int main()
{
    scanf("%lld%lld%lld%lld",&a[0],&a[1],&a[2],&a[3]);
    sort(a,a+4);
    printf("%lld %lld %lld\n",a[3]-a[0],a[3]-a[1],a[3]-a[2]);
}
*/


#include<iostream>
using namespace std;
int main(){

int n1,n2,n3,n4;
cin>>n1>>n2>>n3>>n4;

int b=(n2-n3+n1)/2;
int c=(n3-n1+n2)/2;
int a=(n1-n2+n3)/2;

cout<<a<<" "<<b<<" "<<c-1;

return 0;
}

/*
user >> heguangfu, contest: Codeforces Round #552 (Div. 3), problem: (A) Restoring Three Numbers, Accepted, #, Copy
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define INF 0x3f3f3f3f;
#define fi first
#define se second
#define MP make_pair
#define PI pair<int,int>
#define lson l,m,rt<<1,ls,rs
#define rson m+1,r,rt<<1|1,ls,rs
#define test printf("here!!!\n")
using namespace std;
const int mx=2000+10;
int n,m;
ll a[5];
int main()
{
    scanf("%lld%lld%lld%lld",&a[0],&a[1],&a[2],&a[3]);
    sort(a,a+4);
    printf("%lld %lld %lld\n",a[3]-a[0],a[3]-a[1],a[3]-a[2]);
}
*/


#include<iostream>
using namespace std;
int main(){

int n1,n2,n3,n4;
cin>>n1>>n2>>n3>>n4;

int b=abs(n2-n3+n1)/2;
int c=abs(n3-n1+n2)/2;
int a=abs(n1-n2+n3)/2;

cout<<a<<" "<<b<<" "<<c;

return 0;
}


#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>

using namespace std;

int main()
{
	int* a = new int[4];
	cin >> a[0] >> a[1] >> a[2] >> a[3];
	int sum = 0;
	for (int i = 0; i < 4; i++)
	{
		sum += a[i];
	}
	sum /= 3;
	int* res = new int[3];
	int j = 0;
	for (int i = 0; i < 4; i++)
	{
		if (a[i] != sum)
		{
			res[j] = sum - a[i];
			j++;
		}
	}
	for (int i = 0; i < 3; i++)
	{
		cout << res[i] << " ";
	}
	cout << endl;
	//system("pause");
	return 0;
}


#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>

using namespace std;

int main()
{
	int* a = new int[4];
	cin >> a[0] >> a[1] >> a[2] >> a[3];
	int sum = 0;
	for (int i = 0; i < 4; i++)
	{
		sum += a[i];
	}
	sum /= 3;
	int* res = new int[3];
	int j = 0;
	for (int i = 0; i < 3; i++)
		res[i] = 0;
	for (int i = 0; i < 4; i++)
	{
		if (a[i] != sum)
		{
			res[j] = sum - a[i];
			j++;
		}
	}

	for (int i = 0; i < 3; i++)
	{
		cout << res[i] << " ";
	}
	cout << endl;
	//system("pause");
	return 0;
}


#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>

using namespace std;

int main()
{
	long long* a = new long long[4];
	cin >> a[0] >> a[1] >> a[2] >> a[3];
	int sum = 0;
	for (int i = 0; i < 4; i++)
	{
		sum += a[i];
	}
	sum /= 3;
	long long* res = new long long[3];
	int j = 0;
	for (int i = 0; i < 4; i++)
	{
		if (a[i] != sum)
		{
			res[j] = sum - a[i];
			j++;
		}
	}
	for (int i = 0; i < 3; i++)
		res[i] = 0;
	for (int i = 0; i < 3; i++)
	{
		cout << res[i] << " ";
	}
	cout << endl;
	//system("pause");
	return 0;
}


#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>

using namespace std;

int main()
{
	long long* a = new long long[4];
	cin >> a[0] >> a[1] >> a[2] >> a[3];
	long long sum = 0;
	for (int i = 0; i < 4; i++)
	{
		sum += a[i];
	}
	sum /= 3;
	long long* res = new long long[3];
	int j = 0;
	for (int i = 0; i < 3; i++)
		res[i] = 0;
	for (int i = 0; i < 4; i++)
	{
		if (a[i] != sum)
		{
			res[j] = sum - a[i];
			j++;
		}
	}

	for (int i = 0; i < 3; i++)
	{
		cout << res[i] << " ";
	}
	cout << endl;
	//system("pause");
	return 0;
}


#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>

using namespace std;

int main()
{
	long long* a = new long long[4];
	cin >> a[0] >> a[1] >> a[2] >> a[3];
	int sum = 0;
	for (int i = 0; i < 4; i++)
	{
		sum += a[i];
	}
	sum /= 3;
	long long* res = new long long[3];
	int j = 0;
	for (int i = 0; i < 3; i++)
		res[i] = 0;
	for (int i = 0; i < 4; i++)
	{
		if (a[i] != sum)
		{
			res[j] = sum - a[i];
			j++;
		}
	}

	for (int i = 0; i < 3; i++)
	{
		cout << res[i] << " ";
	}
	cout << endl;
	//system("pause");
	return 0;
}


#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>

using namespace std;

int main()
{
	int* a = new int[4];
	cin >> a[0] >> a[1] >> a[2] >> a[3];
	int sum = 0;
	for (int i = 0; i < 4; i++)
	{
		sum += a[i];
	}
	sum /= 3;
	int* res = new int[3];
	int j = 0;
	for (int i = 0; i < 4; i++)
	{
		if (a[i] != sum)
		{
			res[j] = sum - a[i];
			j++;
		}
	}
	for (int i = 0; i < 3; i++)
	{
		cout << res[i] << " ";
	}
	cout << endl;
	system("pause");
	return 0;
}


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

#define ll long long
#define speed ios::sync_with_stdio(0); cin.tie(0);

int const N = 1000 + 2;

int main(){
  speed
  int a[4];
  cin >> a[0] >> a[1] >> a[2] >> a[3];
  sort(a, a + 4);
  cout << ceil(a[2] / 2.0) << " " << a[2] / 2 << " " << a[3] - a[2] << endl;
}


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

#define ll long long
#define speed ios::sync_with_stdio(0); cin.tie(0);

int const N = 1000 + 2;

int main(){
  speed
  int a[4];
  cin >> a[0] >> a[1] >> a[2] >> a[3];
  sort(a, a + 4);
  cout << a[3] - a[0] << " " << a[3] - a[1] << " " << a[3] - a[2] << endl;
}


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

#define ll long long
#define speed ios::sync_with_stdio(0); cin.tie(0);

int const N = 1000 + 2;

int main(){
  speed
  int a[4];
  cin >> a[0] >> a[1] >> a[2] >> a[3];
  sort(a, a + 4);
  cout << ceil(a[2] / 2.0) << " " << a[2] % (int)ceil(a[2] / 2.0) << " " << a[3] - a[2] << endl;
}


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

#define ll long long
#define speed ios::sync_with_stdio(0); cin.tie(0);

int const N = 1000 + 2;

int main(){
  speed
  int a[4];
  cin >> a[0] >> a[1] >> a[2] >> a[3];
  sort(a, a + 4);
  cout << (a[2] & 1 ? a[2] / 2 + 1 : a[2] / 2) << " " << a[2] / 2 << " " << a[3] - a[2] << endl;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
	long long a[4];
	for (int i = 0; i < 4; ++i) {
		cin >> a[i];
	}

	sort(a, a + 4);
	int sum = a[3];
	int a = sum - a[0];
	int b = sum - a[1];
	int c = sum - a[2];
	cout << a << " " << b << " " << c << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
	long long arr[4];
	for (int i = 0; i < 4; ++i) {
		cin >> arr[i];
	}

	sort(arr, arr + 4);
	long long sum = arr[3];
	long long a = sum - arr[0];
	long long b = sum - arr[1];
	long long c = sum - arr[2];
	cout << a << " " << b << " " << c << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
	long long a[4];
	for (int i = 0; i < 4; ++i) {
		cin >> a[i];
	}

	sort(a, a + 4);
	long long sum = a[3];
	long long a = sum - a[0];
	long long b = sum - a[1];
	long long c = sum - a[2];
	cout << a << " " << b << " " << c << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
	long long a[4];
	for (int i = 0; i < 4; ++i) {
		cin >> a[i];
	}

	sort(a, a + 4);
	int sum = a[3];
	int a = sum - a[0];
	int b = sum - a[1];
	int c = sum - a[2];
	cout << b << " " << a << " " << c << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
	long long arr[4];
	for (int i = 0; i < 4; ++i) {
		cin >> arr[i];
	}

	sort(arr, arr + 4);
	long long sum = a[3];
	long long a = sum - a[0];
	long long b = sum - a[1];
	long long c = sum - a[2];
	cout << a << " " << b << " " << c << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n,i,j,f[200009],d[200009],a[200009],ans=1,mu=1,x,mod=1000000007,ans2=1;
long long po(long long u,long long v)
{
	if(v==0)
		return 1;
	if(v==1)
		return u;
	long long re=po(u,v/2);
	re=(re*re)%mod;
	if(v%2==1)
		return (re*u)%mod;
	return re;
}
int main()
{
	for(i=2;i<=200000;i++)
	{
		if(f[i]==0)
		{
			j=i;
			while(j<=200000)
			{
				f[j]=i;
				j+=i;
			}
		}
	}
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		ans=(ans*x)%mod;
		while(x>1)
		{
			d[f[x]]++;
			x=x/f[x];
		}
	}
	//cout<<ans<<endl;cak
	for(i=1;i<=200000;i++)
		mu*=(d[i]+1),ans2=(ans2*po(i,d[i]/2))%mod;
	//cout<<mu<<endl;
	if(mu%2==1)
		cout<<(po(ans,mu/2)*ans2)%mod;
	else
		cout<<po(ans,mu/2);
}


#include<bits/stdc++.h>
using namespace std;
long long num[200009],dem,n,x,id[200009],f[200009],i,cur,ans=1,d=1,mod=1000000007;
long long po(long long n,long long k)
{
	if(k==1)
		return n;
	long long cak=po(n,k/2);
	cak=cak*cak%mod;
	if(k%2)
		return n*cak%mod;
	return cak;
}
int main()
{
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>x;
		if(id[x]==0)
		{
			dem++;
			id[x]=dem;
			f[dem]=x;
		}
		num[id[x]]++;
	}
	for(i=1;i<=dem;i++)
	{
		cur=po(f[i],num[i]*(num[i]+1)/2);
		ans=po(ans,num[i]+1)*po(cur,d)%mod;
		d=d*(num[i]+1)%(mod-1);
	}
	cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
long long n,i,j,f[200009],d[200009],a[200009],ans=1,mu=1,x,mod=1000000007,ans2=1,kq=1,check;
long long po(long long u,long long v)
{
	if(v==0)
		return 1;
	if(v==1)
		return u;
	long long re=po(u,v/2);
	re=(re*re)%mod;
	if(v%2==1)
		return (re*u)%mod;
	return re;
}
int main()
{
	for(i=2;i<=200000;i++)
	{
		if(f[i]==0)
		{
			j=i;
			while(j<=200000)
			{
				f[j]=i;
				j+=i;
			}
		}
	}
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		ans=(ans*x)%mod;
		while(x>1)
		{
			d[f[x]]++;
			x=x/f[x];
		}
	}
	//cout<<ans<<endl;cak
	for(i=1;i<=200000;i++)
	{
		if(check==0 && d[i]%2==1)
			ans=po(ans,(d[i]+1)/2),check=1;
		else
			ans=po(ans,d[i]+1);
		mu*=(d[i]+1)%2,ans2=(ans2*po(i,d[i]/2))%mod;
	}
	if(mu==1)
		cout<<(ans*ans2)%mod;
	else
		cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
long long n,i,j,f[200009],d[200009],a[200009],ans=1,mu=1,x,mod=1000000007,ans2=1;
long long po(long long u,long long v)
{
	if(v==0)
		return 1;
	if(v==1)
		return u;
	long long re=po(u,v/2);
	re=(re*re)%mod;
	if(v%2==1)
		return (re*u)%mod;
	return re;
}
int main()
{
	for(i=2;i<=200000;i++)
	{
		if(f[i]==0)
		{
			j=i;
			while(j<=200000)
			{
				f[j]=i;
				j+=i;
			}
		}
	}
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		ans=(ans*x)%mod;
		while(x>1)
		{
			d[f[x]]++;
			x=x/f[x];
		}
	}
	//cout<<ans<<endl;
	for(i=1;i<=200000;i++)
		mu*=(d[i]+1),ans2=(ans2*po(i,d[i]/2))%mod;
	//cout<<mu<<endl;
	if(mu%2==1)
		cout<<po(ans,mu/2)*ans2;
	else
		cout<<po(ans,mu/2);
}


#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define F first
#define S second
using namespace std;
const ll mod=1e9+7;
ll tavan(ll a,ll b)
{
	if(b==0) return 1;
	a%=mod;
	return (((b%2)?a:1)*tavan((a*a)%mod,b/2))%mod;
}
map<ll,ll> mp;
ll ans=1,d=1;
int main()
{
	ll n;cin>>n;
	for(ll i=0;i<n;i++) {ll x;cin>>x;mp[x]++;}
	for(map<ll,ll>::iterator it=mp.begin();it!=mp.end();it++)
	{
		pll p=*it;
		ans=tavan(ans,p.S+1);ans*=tavan(tavan(p.F,(p.S*(p.S+1))/2),d);ans%=mod;
		d*=p.S+1;d%=mod-1;
	}
	cout<<ans;
}


#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define F first
#define S second
using namespace std;
const ll mod=1e9+7;
ll tavan(ll a,ll b)
{
	if(b==0) return 1;
	a%=mod;
	return (((b%2)?a:1)*tavan((a*a)%mod,b/2))%mod;
}
map<ll,ll> mp;
ll ans=1,d=1;
int main()
{
	ll n;cin>>n;
	for(ll i=0;i<n;i++) {ll x;cin>>x;mp[x]++;}
	for(map<ll,ll>::iterator it=mp.begin();it!=mp.end();it++)
	{
		pll p=*it;
		ans=tavan(ans,p.S+1);ans*=tavan(tavan(p.F,(p.S*(p.S+1))/2),d);d*=p.S+1;d%=mod;
	}
	cout<<ans;
}


#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define pll pair<ll,ll>
#define PB push_back
#define MP make_pair
using namespace std;
map<ll,ll> mp;
ll pow(ll a,ll b)
{
	ll ans=1;
	for(ll i=0;i<b;i++) ans*=a;
	return ans;
}
int main()
{
	ll m,n=1;cin>>m;for(ll i=0;i<m;i++) {ll x;cin>>x;n*=x;mp[x]++;}
	ll s=1;
	for(map<ll,ll>::iterator it=mp.begin();it!=mp.end();it++)
	s*=((*it).S+1);
	ll ans=((s%2)?sqrt(n):1);
	ans*=pow(n,s/2);
	cout<<ans;
}


#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define F first
#define S second
using namespace std;
const ll mod=1e9+7;
ll tavan(ll a,ll b)
{
	if(b==0) return 1;
	a%=mod;
	return (((b%2)?a:1)*tavan((a*a)%mod,b/2))%mod;
}
map<ll,ll> mp;
ll ans=1,d=1;
int main()
{
	ll n;cin>>n;
	for(ll i=0;i<n;i++) {ll x;cin>>x;mp[x]++;}
	for(map<ll,ll>::iterator it=mp.begin();it!=mp.end();it++)
	{
		pll p=*it;
		ans=tavan(ans,p.S+1);ans*=tavan(tavan(p.F,(p.S*(p.S+1))/2),d);d*=p.S+1;d%=mod-1;
	}
	cout<<ans;
}


#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define F first
#define S second
using namespace std;
const ll mod=1e9+7;
ll tavan(ll a,ll b)
{
	if(b==0) return 1;
	a%=mod;
	return (((b%2)?a:1)*tavan((a*a)%mod,b/2))%mod;
}
map<ll,ll> mp;
ll ans=1,d=1;
int main()
{
	ll n;cin>>n;
	for(ll i=0;i<n;i++) {ll x;cin>>x;mp[x]++;}
	for(map<ll,ll>::iterator it=mp.begin();it!=mp.end();it++)
	{
		pll p=*it;
		ans=tavan(ans,p.S+1);ans*=tavan(tavan(p.F,(p.S*(p.S+1))/2),d);d*=p.S+1;//d%=mod;
	}
	cout<<ans;
}


//This code is solely the property of StarnyC
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define hell 1000000007
#define reset(a,b) memset(a,b,sizeof(a))
#define Go_Baby_Go  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0);

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

ll binexp(ll x,ll n,ll m){
   if(!n)return 1;
else if(n&1)return (x%m)*binexp((x%m)*(x%m),n/2,m)%m;
else if(!(n&1))return binexp((x%m)*(x%m),n/2,m)%m;
return 0;}

int solve(ll _,ll _t)
{
	int n;
	cin>>n;
	map <int,int> divcnt;
	for(int i=0;i<n;i++)
	{	int x;
		cin>>x;
		divcnt[x]++;
	}

	ll power=1,ans=1;
	int b=0;
	for(auto it:divcnt){if(it.second%2==1){b=1;break;}}

	if(b==1){//cout<<"F1";
	for(auto it:divcnt)
		{power*=((it.second)+1)%(2*(hell-1));
			power%=2*(hell-1);
		}
		power/=2;
	power%=(hell-1);

	for(auto it:divcnt)
		{ans*=binexp(it.first,(((power%(hell-1))*((it.second)%(hell-1)))%(hell-1)),hell);ans%=hell;
		}
	}

	else{//cout<<"F2";
		for(auto it:divcnt)
			{power*=((it.second)+1)%(2*(hell-1));power%=2*(hell-1);}
		power/=2;power%=hell-1;
		for(auto it:divcnt)
			{ans*=binexp(it.first,(((power%(hell-1))*((it.second)%(hell-1)))%(hell-1)),hell);ans%=hell;}
		for(auto it:divcnt)
			{ans*=binexp(it.first,it.second/2,hell);ans%=hell;}
	}

cout<<ans%hell;

return 0;
}

int main()
{
Go_Baby_Go
//cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" ;

ll _=1;
//cin>>_;
ll _t=_;
while(_--)
solve(_,_t);

}


//This code is solely the property of StarnyC
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define hell 1000000007
#define reset(a,b) memset(a,b,sizeof(a))
#define Go_Baby_Go  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0);

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

ll binexp(ll x,ll n,ll m){
   if(!n)return 1;
else if(n&1)return (x%m)*binexp((x%m)*(x%m),n/2,m)%m;
else if(!(n&1))return binexp((x%m)*(x%m),n/2,m)%m;
return 0;}

int solve(ll _,ll _t)
{
	int n;
	cin>>n;
	map <int,int> divcnt;
	for(int i=0;i<n;i++)
	{	int x;
		cin>>x;
		divcnt[x]++;
	}

	ll power=1,ans=1;
	int b=0;
	for(auto it:divcnt){if(it.second%2==1){b=1;break;}}

	if(b==1){
	for(auto it:divcnt)
		{power*=((it.second)+1)%(hell-1);power%=hell-1;}
	power%=hell-1;
	power/=2;
	for(auto it:divcnt)
		{ans*=binexp(it.first,power*(it.second),hell);ans%=hell;}
	}

	else{
		for(auto it:divcnt)
			{power*=((it.second)+1)%(hell-1);}
		power/=2;power%=hell-1;
		for(auto it:divcnt)
			{ans*=binexp(it.first,power*(it.second),hell);ans%=hell;}
		for(auto it:divcnt)
			{ans*=binexp(it.first,it.second/2,hell);ans%=hell;}
	}

cout<<ans%hell;

return 0;
}

int main()
{
Go_Baby_Go
//cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" ;

ll _=1;
//cin>>_;
ll _t=_;
while(_--)
solve(_,_t);

}


//This code is solely the property of StarnyC
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define hell 1000000007
#define reset(a,b) memset(a,b,sizeof(a))
#define Go_Baby_Go  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0);

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

ll binexp(ll x,ll n,ll m){
   if(!n)return 1;
else if(n&1)return (x%m)*binexp((x%m)*(x%m),n/2,m)%m;
else if(!(n&1))return binexp((x%m)*(x%m),n/2,m)%m;
return 0;}

int solve(ll _,ll _t)
{
	int n;
	cin>>n;
	map <int,int> divcnt;
	for(int i=0;i<n;i++)
	{	int x;
		cin>>x;
		divcnt[x]++;
	}

	ll power=1,ans=1;
	int b=0;
	for(auto it:divcnt){if(it.second%2==1){b=1;break;}}

	if(b==1){//cout<<"F1";
	for(auto it:divcnt)
		{power*=((it.second)+1)%(2*(hell-1));
			power%=2*(hell-1);
		}
		power/=2;
	power%=(hell-1);

	for(auto it:divcnt)
		{ans*=binexp(it.first,(((power%(hell-1))*((it.second)%(hell-1)))%(hell-1)),hell);ans%=hell;
		}
	}

	else{//cout<<"F2";
		for(auto it:divcnt)
			{power*=((it.second)+1)%(2*(hell-1));}
		power/=2;power%=hell-1;
		for(auto it:divcnt)
			{ans*=binexp(it.first,(((power%(hell-1))*((it.second)%(hell-1)))%(hell-1)),hell);ans%=hell;}
		for(auto it:divcnt)
			{ans*=binexp(it.first,it.second/2,hell);ans%=hell;}
	}

cout<<ans%hell;

return 0;
}

int main()
{
Go_Baby_Go
//cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" ;

ll _=1;
//cin>>_;
ll _t=_;
while(_--)
solve(_,_t);

}


//This code is solely the property of StarnyC
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define hell 1000000007
#define reset(a,b) memset(a,b,sizeof(a))
#define Go_Baby_Go  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0);

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

ll binexp(ll x,ll n,ll m){
   if(!n)return 1;
else if(n&1)return (x%m)*binexp((x%m)*(x%m),n/2,m)%m;
else if(!(n&1))return binexp((x%m)*(x%m),n/2,m)%m;
return 0;}

int solve(ll _,ll _t)
{
	int n;
	cin>>n;
	map <int,int> divcnt;
	for(int i=0;i<n;i++)
	{	int x;
		cin>>x;
		divcnt[x]++;
	}

	ll power=1,ans=1;
	int b=0;
	for(auto it:divcnt){if(it.second%2==1){b=1;break;}}

	if(b==1){
	for(auto it:divcnt)
		{power*=((it.second)+1)%(hell-1);}
	power/=2;
	for(auto it:divcnt)
		{ans*=binexp(it.first,power*(it.second),hell);}
	}

	else{
		for(auto it:divcnt)
			{power*=((it.second)+1)%(hell-1);}
		power/=2;
		for(auto it:divcnt)
			{ans*=binexp(it.first,power*(it.second),hell);}
		for(auto it:divcnt)
			{ans*=binexp(it.first,it.second/2,hell);}
	}

cout<<ans%hell;

return 0;
}

int main()
{
Go_Baby_Go
//cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" ;

ll _=1;
//cin>>_;
ll _t=_;
while(_--)
solve(_,_t);

}


//This code is solely the property of StarnyC
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define hell 1000000007
#define reset(a,b) memset(a,b,sizeof(a))
#define Go_Baby_Go  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0);

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

ll binexp(ll x,ll n,ll m){
   if(!n)return 1;
else if(n&1)return (x%m)*binexp((x%m)*(x%m),n/2,m)%m;
else if(!(n&1))return binexp((x%m)*(x%m),n/2,m)%m;
return 0;}

int solve(ll _,ll _t)
{
	int n;
	cin>>n;
	map <int,int> divcnt;
	for(int i=0;i<n;i++)
	{	int x;
		cin>>x;
		divcnt[x]++;
	}

	ll power=1,ans=1;
	int b=0;
	for(auto it:divcnt){if(it.second%2==1){b=1;break;}}

	if(b==1){
	for(auto it:divcnt)
		{power*=((it.second)+1)%(hell-1);}
	power/=2;
	for(auto it:divcnt)
		{ans*=binexp(it.first,power*(it.second),hell);}
	}

	else{
		for(auto it:divcnt)
			{power*=((it.second)+1)%(hell-1);}
		power/=2;
		for(auto it:divcnt)
			{ans*=binexp(it.first,power*(it.second),hell);}
		for(auto it:divcnt)
			{ans*=binexp(it.first,it.second/2,hell);}
	}

cout<<ans;

return 0;
}

int main()
{
Go_Baby_Go
//cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" ;

ll _=1;
//cin>>_;
ll _t=_;
while(_--)
solve(_,_t);

}


#include <bits/stdc++.h>
using namespace std; bool ooo = 1; template <typename T> ostream& operator << (ostream& _o_, const vector <T> &_v_) { if(!_v_.empty()) {_o_ << '['; copy(_v_.begin(), _v_.end(), ostream_iterator <T> (_o_, ", ")); _o_ << "\b\b]"; } return _o_; } struct Dbg { template <typename T> Dbg& operator, (const T& v) { cerr << v << ", "; return *this; } } Dbg;
#define debug(args...)  if(ooo) { cout << #args << " = "; Dbg, args; cout << endl; }

const int N = 200000, mod = 1e9 + 7;

int m, p[N + 2], cnt[N + 2], total = 1, ans = 1;

int binpow(int n, int k) {
	int ans = 1;
	while(k) {
		if(k & 1) ans = (ans * n) % mod;
		n = (n * n) % mod;
		k >>= 1;
	}
	return ans;
}

signed main() {
	cin >> m;
	for(int i = 1; i <= m; i++) {
		cin >> p[i];
		cnt[p[i]]++;
		ans = (ans * p[i]) % mod;
	}
	int t1 = 0, t2 = 0;
	for(int i = 1; i <= N; i++) {
		if(cnt[i]) {
			if(cnt[i] % 2 == 0) {
				t1++;
			}
			t2++;
		}
	}
	if(t1 == t2) {
		int ans = 1;
		for(int i = 1; i <= N; i++) {
			if(cnt[i]) {
				ans = (ans * binpow(i, cnt[i] / 2)) % mod;
				int tmp = cnt[i] + 1;
				total = (total * tmp) % (mod - 1);
			}
		}
		ans = binpow(ans, total);
		return cout << ans, 0;
	}
	bool ok = 1;
	for(int i = 1; i <= N; i++) {
		if(cnt[i]) {
			int tmp = cnt[i] + 1;
			if(tmp % 2 == 0 && ok) tmp /= 2, ok = 0;
			total = (total * tmp) % (mod - 1);
		}
	}
	debug(total);
	ans = binpow(ans, total);
	cout << ans;
}


#include <bits/stdc++.h>
using namespace std; bool ooo = 0; template <typename T> ostream& operator << (ostream& _o_, const vector <T> &_v_) { if(!_v_.empty()) {_o_ << '['; copy(_v_.begin(), _v_.end(), ostream_iterator <T> (_o_, ", ")); _o_ << "\b\b]"; } return _o_; } struct Dbg { template <typename T> Dbg& operator, (const T& v) { cout << v << ", "; return *this; } } Dbg;
#define debug(args...)  if(ooo) { cout << #args << " = "; Dbg, args; cout << endl; }
#define int long long
struct _ { _() {
#ifndef ONLINE_JUDGE
ooo = 1;
#endif
ios_base::sync_with_stdio(0); cin.tie(0); } } _;
const int N = 200000, mod = 1e9 + 7;
int m, p[N + 2], cnt[N + 2], total = 1, ans = 1;

int binpow(int n, int k) {
	int ans = 1;
	while(k) {
		if(k & 1) ans = (ans * n) % mod;
		n = (n * n) % mod;
		k >>= 1;
	}
	return ans;
}

signed main() {
	cin >> m;
	for(int i = 1; i <= m; i++) {
		cin >> p[i];
		cnt[p[i]]++;
		ans = (ans * p[i]) % mod;
	}
	int t1 = 0, t2 = 0;
	for(int i = 1; i <= N; i++) {
		if(cnt[i]) {
			if(cnt[i] % 2 == 0) {
				t1++;
			}
			t2++;
		}
	}
	if(t1 == t2) {
		int ans = 1;
		for(int i = 1; i <= N; i++) {
			if(cnt[i]) {
				ans = (ans * binpow(i, cnt[i] / 2)) % mod;
				int tmp = cnt[i] + 1;
				total = (total * tmp) % (mod - 1);
			}
		}
		ans = binpow(ans, total);
		return cout << ans, 0;
	}
	bool ok = 1;
	for(int i = 1; i <= N; i++) {
		if(cnt[i]) {
			int tmp = cnt[i] + 1;
			if(tmp % 2 == 0 && ok) tmp /= 2, ok = 0;
			total = (total * tmp) % (mod - 1);
		}
	}
	debug(total);
	ans = binpow(ans, total);
	cout << ans;
}


#include <bits/stdc++.h>
using namespace std; bool ooo = 0; template <typename T> ostream& operator << (ostream& _o_, const vector <T> &_v_) { if(!_v_.empty()) {_o_ << '['; copy(_v_.begin(), _v_.end(), ostream_iterator <T> (_o_, ", ")); _o_ << "\b\b]"; } return _o_; } struct Dbg { template <typename T> Dbg& operator, (const T& v) { cout << v << ", "; return *this; } } Dbg;
#define debug(args...)  if(ooo) { cout << #args << " = "; Dbg, args; cout << endl; }

const int N = 200000, mod = 1e9 + 7;

int m, p[N + 2], cnt[N + 2], total = 1, ans = 1;

int binpow(int n, int k) {
	int ans = 1;
	while(k) {
		if(k & 1) ans = (ans * n) % mod;
		n = (n * n) % mod;
		k >>= 1;
	}
	return ans;
}

signed main() {
	#ifndef LOCAL
	ooo = 1;
	#endif
	cin >> m;
	for(int i = 1; i <= m; i++) {
		cin >> p[i];
		cnt[p[i]]++;
		ans = (ans * p[i]) % mod;
	}
	int t1 = 0, t2 = 0;
	for(int i = 1; i <= N; i++) {
		if(cnt[i]) {
			if(cnt[i] % 2 == 0) {
				t1++;
			}
			t2++;
		}
	}
	if(t1 == t2) {
		int ans = 1;
		for(int i = 1; i <= N; i++) {
			if(cnt[i]) {
				ans = (ans * binpow(i, cnt[i] / 2)) % mod;
				int tmp = cnt[i] + 1;
				total = (total * tmp) % (mod - 1);
			}
		}
		ans = binpow(ans, total);
		return cout << ans, 0;
	}
	bool ok = 1;
	for(int i = 1; i <= N; i++) {
		if(cnt[i]) {
			int tmp = cnt[i] + 1;
			if(tmp % 2 == 0 && ok) tmp /= 2, ok = 0;
			total = (total * tmp) % (mod - 1);
		}
	}
	debug(total);
	ans = binpow(ans, total);
	cout << ans;
}


#include <bits/stdc++.h>
using namespace std; bool ooo = 0; template <typename T> ostream& operator << (ostream& _o_, const vector <T> &_v_) { if(!_v_.empty()) {_o_ << '['; copy(_v_.begin(), _v_.end(), ostream_iterator <T> (_o_, ", ")); _o_ << "\b\b]"; } return _o_; } struct Dbg { template <typename T> Dbg& operator, (const T& v) { cout << v << ", "; return *this; } } Dbg;
#define debug(args...)  if(ooo) { cout << #args << " = "; Dbg, args; cout << endl; }

const int N = 200000, mod = 1e9 + 7;

int m, p[N + 2], cnt[N + 2], total = 1, ans = 1;

int binpow(int n, int k) {
	int ans = 1;
	while(k) {
		if(k & 1) ans = (ans * n) % mod;
		n = (n * n) % mod;
		k >>= 1;
	}
	return ans;
}

signed main() {
	#ifdef LOCAL
	ooo = 1;
	#endif
	cin >> m;
	for(int i = 1; i <= m; i++) {
		cin >> p[i];
		cnt[p[i]]++;
		ans = (ans * p[i]) % mod;
	}
	int t1 = 0, t2 = 0;
	for(int i = 1; i <= N; i++) {
		if(cnt[i]) {
			if(cnt[i] % 2 == 0) {
				t1++;
			}
			t2++;
		}
	}
	if(t1 == t2) {
		int ans = 1;
		for(int i = 1; i <= N; i++) {
			if(cnt[i]) {
				ans = (ans * binpow(i, cnt[i] / 2)) % mod;
				int tmp = cnt[i] + 1;
				total = (total * tmp) % (mod - 1);
			}
		}
		ans = binpow(ans, total);
		return cout << ans, 0;
	}
	bool ok = 1;
	for(int i = 1; i <= N; i++) {
		if(cnt[i]) {
			int tmp = cnt[i] + 1;
			if(tmp % 2 == 0 && ok) tmp /= 2, ok = 0;
			total = (total * tmp) % (mod - 1);
		}
	}
	debug(total);
	ans = binpow(ans, total);
	cout << ans;
}


#include <bits/stdc++.h>
using namespace std; bool ooo = 0; template <typename T> ostream& operator << (ostream& _o_, const vector <T> &_v_) { if(!_v_.empty()) {_o_ << '['; copy(_v_.begin(), _v_.end(), ostream_iterator <T> (_o_, ", ")); _o_ << "\b\b]"; } return _o_; } struct Dbg { template <typename T> Dbg& operator, (const T& v) { cout << v << ", "; return *this; } } Dbg;
#define debug(args...)  if(ooo) { cout << #args << " = "; Dbg, args; cout << endl; }
#define int long long
const int N = 200000, mod = 1e9 + 7;

int m, p[N + 2], cnt[N + 2], total = 1, ans = 1;

int binpow(int n, int k) {
	int ans = 1;
	while(k) {
		if(k & 1) ans = (ans * n) % mod;
		n = (n * n) % mod;
		k >>= 1;
	}
	return ans;
}

signed main() {
	#ifdef LOCAL
	ooo = 1;
	#endif
	cin >> m;
	for(int i = 1; i <= m; i++) {
		cin >> p[i];
		cnt[p[i]]++;
		ans = (ans * p[i]) % mod;
	}
	int t1 = 0, t2 = 0;
	for(int i = 1; i <= N; i++) {
		if(cnt[i]) {
			if(cnt[i] % 2 == 0) {
				t1++;
			}
			t2++;
		}
	}
	if(t1 == t2) {
		int ans = 1;
		for(int i = 1; i <= N; i++) {
			if(cnt[i]) {
				ans = (ans * binpow(i, cnt[i] / 2)) % mod;
				int tmp = cnt[i] + 1;
				total = (total * tmp) % (mod - 1);
			}
		}
		ans = binpow(ans, total);
		return cout << ans, 0;
	}
	bool ok = 1;
	for(int i = 1; i <= N; i++) {
		if(cnt[i]) {
			int tmp = cnt[i] + 1;
			if(tmp % 2 == 0 && ok) tmp /= 2, ok = 0;
			total = (total * tmp) % (mod - 1);
		}
	}
	debug(total);
	ans = binpow(ans, total);
	cout << ans;
}


#include <bits/stdc++.h>
using namespace std; bool ooo = 0; template <typename T> ostream& operator << (ostream& _o_, const vector <T> &_v_) { if(!_v_.empty()) {_o_ << '['; copy(_v_.begin(), _v_.end(), ostream_iterator <T> (_o_, ", ")); _o_ << "\b\b]"; } return _o_; } struct Dbg { template <typename T> Dbg& operator, (const T& v) { cout << v << ", "; return *this; } } Dbg;
#define debug(args...)  if(ooo) { cout << #args << " = "; Dbg, args; cout << endl; }
// #define int long long
struct _ { _() {
#ifndef ONLINE_JUDGE
ooo = 1;
#endif
ios_base::sync_with_stdio(0); cin.tie(0); } } _;
const int N = 200000, mod = 1e9 + 7;
int m, p[N + 2], cnt[N + 2], total = 1, ans = 1;

int binpow(int n, int k) {
	int ans = 1;
	while(k) {
		if(k & 1) ans = (ans * n) % mod;
		n = (n * n) % mod;
		k >>= 1;
	}
	return ans;
}

signed main() {
	cin >> m;
	for(int i = 1; i <= m; i++) {
		cin >> p[i];
		cnt[p[i]]++;
		ans = (ans * p[i]) % mod;
	}
	int t1 = 0, t2 = 0;
	for(int i = 1; i <= N; i++) {
		if(cnt[i]) {
			if(cnt[i] % 2 == 0) {
				t1++;
			}
			t2++;
		}
	}
	if(t1 == t2) {
		int ans = 1;
		for(int i = 1; i <= N; i++) {
			if(cnt[i]) {
				ans = (ans * binpow(i, cnt[i] / 2)) % mod;
				int tmp = cnt[i] + 1;
				total = (total * tmp) % (mod - 1);
			}
		}
		ans = binpow(ans, total);
		return cout << ans, 0;
	}
	bool ok = 1;
	for(int i = 1; i <= N; i++) {
		if(cnt[i]) {
			int tmp = cnt[i] + 1;
			if(tmp % 2 == 0 && ok) tmp /= 2, ok = 0;
			total = (total * tmp) % (mod - 1);
		}
	}
	debug(total);
	ans = binpow(ans, total);
	cout << ans;
}


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

#define ll       long long
#define ull      unsigned long long
#define ld       long double
#define pii      pair<int,int>
#define pll      pair<ll,ll>
#define vi       vector<int>
#define vll      vector<ll>
#define vc       vector<char>
#define vs       vector<string>
#define vpii     vector< pair<int,int> >
#define vpll     vector< pair<ll,ll> >
#define pip      pair< int,pii >
#define ppi      pair< pii,int >
#define sei      set<int>
#define usei     unordered_set<int>
#define ses      set<string>
#define sepii    set< pair<int,int> >
#define di       deque<int>
#define li       list<int>
#define sti      stack<int>
#define qi       queue<int>
#define pqi      priority_queue<int>
#define mpii      map<int,int>
#define mpll      map<ll,ll>
#define umii     unordered_map<int,int>
#define vit      vector<int>::iterator
#define mit      map<int,int>::iterator
#define sit      set<int>:: iterator
#define umap     unordered_map
#define uset     unordered_set
#define PQ       priority_queue

#define rep(i,n)        for(i=0;i<n;i++)
#define itfor(i, c)     for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define printa(a,L,R)   for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define printv(a)       printa(a,0,a.size())
#define print2d(a,r,c)  for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?'\n':' ')
#define pb              push_back
#define MP              make_pair
#define SQ(x)           ((x)*(x))
#define F               first
#define S               second
#define mem(a,x)        memset(a,x,sizeof(a))
#define inf             0x3f3f3f3f
#define PI              3.14159265358979323846
#define E               2.71828182845904523536
#define gamma           0.5772156649
#define nl              "\n"
#define lg(r,n)         (int)(log2(n)/log2(r))
#define sf(a)           scanf("%d",&a)
#define sfl(a)          scanf("%lld",&a)
#define sfc(a)          scanf("%c",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sffl(a,b)       scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%lld %lld %lld",&a,&b,&c)
#define pf              printf
#define pfi(a)          pf("%d\n",&a)
#define pfl(a)          pf("%lld\n",&a)
#define _ccase          printf("Case %d: ",++cs)
#define _case           cout<<"Case "<<++cs<<": "
#define debug(x)        cout<<#x"="<<(x)<<nl

#define rev(v)              reverse(v.begin(),v.end())
#define srt(v)              sort(v.begin(),v.end())
#define grtsrt(v)           sort(v.begin(),v.end(),greater<int>())
#define all(v)              v.begin(),v.end()
#define mnv(v)              *min_element(v.begin(),v.end())
#define mxv(v)              *max_element(v.begin(),v.end())
#define countv(v,a)         count(v.begin(),v.end(),a)
#define toint(a)            atoi(a.c_str())
#define fast                ios_base::sync_with_stdio(false),cin.tie(NULL)
string  tostr(int n)        {stringstream rr;rr<<n;return rr.str();}
const int mod=1e9+6;
ll qpow(ll n,ll k)          {ll ans=1;while(k){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans;}
const int mxn=2e5+9;
const ld eps=1e-9;

ll i,j,k,n,ans=1,freq[mxn],tmp,tmp2,lmul[mxn],rmul[mxn];
int main()
{
    fast;
    cin>>n;
    rep(i,n) cin>>k,freq[k]++;
    lmul[0]=1;
    for(i=1;i<mxn;i++) lmul[i]=(lmul[i-1]*(freq[i]+1))%mod;
    rmul[mxn-1]=1;
    for(i=mxn-2;i>=0;i--) rmul[i]=(rmul[i+1]*(freq[i]+1))%mod;
    for(i=1;i<mxn;i++){
        if(freq[i]){
            k=(freq[i]*(freq[i]+1)/2)%mod;
            tmp=(lmul[i-1]*rmul[i+1])%mod;
            tmp2=qpow(i,(k*tmp)%mod);
            ans=(ans*tmp2)%mod;
        }
    }
    cout<<ans<<nl;
    return 0;
}