#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repn(i, n) for (int i = (int)(n)-1; i>= 0; --i)
#define ll long long
using Graph = vector<vector<int>>;
int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    vector<bool> numa(1000, false), numb(1000, false);
    rep1(i, 1, 1001){
        if (find(a.begin(), a.end(), i) != a.end()) numa[i-1] = true;
        if (find(b.begin(), b.end(), i) != b.end()) numb[i-1] = true;
    }
    rep(i, 1000){
        if ((numa[i] == true && numb[i] == false) || (numb[i] == true && numa[i] == false)){
            cout << i+1 << " ";
        }
    }
    cout << endl;
}
//Fuck the world....don't care anyone........................................................
#include <bits/stdc++.h>
#include<bitset>
#include<iostream>
using namespace std;
#include<math.h>
#include<map>
#include<vector>
#include<string>
#include<algorithm>
#define ll long long
#define ld double
#include<stdio.h>
#define f first
#define s second
#include<stack>
#include<queue>
#define its set<int>::iterator
#define itmp map<int,int>::iterator
#include<stack>
#define lp for(int i=0;i<n;i++)
#define dlp for(int i=0;i<n;i++) for(int j=0;j<n;j++)
#define mod 1000000009
//#define N 101
//#include <boost/functional/hash.hpp>
//bitset<1000> b;
//b.set();   all bit have 1
//seive of Erat
//totient theorm for co-prime
/*ll int N=1000;
	int p[1001]={0};
	p[2]=1;
		vector<int>v;
        for(ll int i=3;i<=N;i+=2)
        p[i]=1;
        v.push_back(2);
        for(ll int i=3;i<=N;i+=2)
        {
            if(p[i])
            {
			v.push_back(i);
                for(ll int j=i*i;j<=N;j+=2*i)
                p[j]=0;
            }
        }  */
/*
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} */
/*
stringstream ss;  
ss<<c;  
string s1;
ss>>s1;
*/
/*
int power(int x, unsigned int y) 
{ 
    int temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2); 
    if (y%2 == 0) 
        return temp*temp; 
    else
        return x*temp*temp; 
}*/
int main()
{
	ios_base::sync_with_stdio(false); 
    	cin.tie(NULL); 
	 
      	ll int t=1;
	
	while(t--)
	{
            // vector<pair<ll,ll> >v;
            ll n;
            cin>>n;
            ll a[n];
             set<ll>s;
            lp
            {
                cin>>a[i];
                s.insert(a[i]);
            }
           
            set<ll>::reverse_iterator rit; 
            set<ll>::iterator it;
            
            while(1)
            {
                rit=s.rbegin();

                it=s.begin();
                //cout<<*it<<" "<<*rit<<endl;
                if(*rit==*it)
                {
                    cout<<*it<<endl;
                    return 0;
                }
                //cout<<*rit<<endl;
                s.insert(*rit-*it); 
                s.erase(*rit);
                
            }
       
    }
           
            return 0;
           
    
    }
	
