/* NEVER GIVE UP */
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define vi             vector<ll>
#define mi             map<ll,ll>
#define pi             pair<ll,ll>
#define si             set<ll>
#define endl            "\n"
#define N              1000000007
#define PI              3.1415926535897932384
#define inf             1000000000000000005
#define ll              long long
#define f               first
#define s              second
#define pb             push_back
#define fr(n)          for(ll i=0;i<n;i++)
#define FAST           ios_base::sync_with_stdio(false); cin.tie(NULL);
#define NN             998244353
#define mem1(vis)     memset(vis,-1,sizeof(vis))
#define mem0(vis)     memset(vis,0,sizeof(vis));
#define DECIMAL(n)  std::cout << std::fixed;std::cout << std::setprecision(n);
#define make make_pair
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define sz(a) (int)a.size()
#define loop(i,a,b) for(ll i=a;i<=b;i++)

/*
CHAR_BIT       = number of bits in a char
CHAR_MIN/MAX   = min/max value for a char
INT_MIN/MAX    = min/max value for an int
LLONG_MIN/MAX  = min/max value for a long long
*/

//std::ifstream in("input.txt");
//std::ofstream out("output.txt");
/*ll prime(ll n)
{
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        return 0;
    }
    return 1;
}

ll find(ll n)
{
    while(1)
    {
        if(n==parent[n])
        return n;
        else
        n=parent[n];
    }
}
void union(ll a,ll b)
{
    ll x=find(a);
    ll y=find(b);
    if(x==y)
    return ;
    else
    parent[x]=y;
}
//ll dp[500001][500001];

ll power(ll x,ll y,ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {

        if (y & 1)
            res = (res*x) % p;

        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll modInverse(ll n,ll p)
{
   return power(n, p-2, p);
}
*/
void buildtree(ll *tree,ll *a,ll index,ll start,ll end)
{
    if(start>end)
    return ;
    if(start==end)
    {
        tree[index]=a[start];
        return;
    }
    ll mid=(start+end)/2;
    buildtree(tree,a,2*index,start,mid);
    buildtree(tree,a,2*index+1,mid+1,end);
    ll left=tree[2*index];
    ll right=tree[2*index+1];
    tree[index]=left+right;
    return ;
}
ll query(ll *tree,ll index,ll s,ll e,ll qs,ll qe)
{
    // no overlap
    if(qs>e||s>qe)
    return 0;
    if(qe>=e&&s>=qs)// complete overlap
    {
        return tree[index];
    }
    ll mid=(s+e)/2;
    ll left=query(tree,2*index,s,mid,qs,qe);
    ll right=query(tree,2*index+1,mid+1,e,qs,qe);
    return left+right;
}
void updatenode(ll *tree,ll index,ll s,ll e,ll i,ll val)
{
    if(i>e||i<s)
    return ;
    if(s==e)
    {
        tree[index]+=val;
        return ;
    }
    ll mid=(s+e)/2;
    updatenode(tree,2*index,s,mid,i,val);
    updatenode(tree,2*index+1,mid+1,e,i,val);
    tree[index]=tree[2*index]+tree[2*index+1];
    return ;
}
/*
void updaterange(ll *tree,ll index,ll s,ll e,ll rs,ll re,ll val)
{
    if(rs>e||s>re)
    return ;
    if(s==e)
    {
        tree[index]=val;
        return ;
    }
    ll mid=(s+e)/2;
    updaterange(tree,2*index,s,mid,rs,re,val);
    updaterange(tree,2*index+1,mid+1,e,rs,re,val);
    ll left=tree[2*index];
    ll right=tree[2*index+1];
    tree[index]=min(left,right);
    return ;
}*/
int main()
{
    ll n,q,x;
    cin>>n>>q;
    ll g=log2(n);
    ll a[n+1];
    mem0(a);
    loop(i,1,n)//={1,2,3,4,5,60};
    {
        cin>>x;
        a[x]++;
    }
    g++;
    ll *tree=new ll[(ll)(pow(2,g+1)+5.5)];
    ll index=1;
    ll start=1;
    ll end=n;
    buildtree(tree,a,index,start,end);
    //cout<<query(tree,1,1,n,1,n)<<endl;
    while(q--)
    {
        cin>>x;
        if(x>0)
        {
            updatenode(tree,1,1,n,x,1);
        }
        else
        {
            ll z=abs(x);
            ll l=1,r=n;

            while(r-l>1)
            {
                ll mid=(l+r)/2;
                ll y=query(tree,1,1,n,l,mid);
                //cout<<l<<" "<<r<<" y "<<" "<<y<<" ";
                if(y>=z)
                {
                    r=mid;
                }
                else //if(y<z)
                {
                    l=mid;
                }

            }

            if(query(tree,1,1,n,1,l)>=z)
            {
      //          cout<<l<<" ";
                updatenode(tree,1,1,n,l,-1);
            }
            else
            {
        //        cout<<r<<" ";
                updatenode(tree,1,1,n,r,-1);
            }
          //  cout<<query(tree,1,1,n,1,n)<<endl;
        }
     }

    // cout<<endl;
     for(ll i=1;i<=n;i++)
     {
         ll y=query(tree,1,1,n,1,i);
         if(y>0)
         {
             cout<<i;
             return 0;
         }
     }
     cout<<0;
    return 0;
}


/* EK BAAR AUR */
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define vi             vector<ll>
#define mi             map<ll,ll>
#define pi             pair<ll,ll>
#define si             set<ll>
#define endl            "\n"
#define N              1000000007
#define PI              3.1415926535897932384
#define inf             1000000000000000005
#define ll              long long
#define f               first
#define s              second
#define pb             push_back
#define fr(n)          for(ll i=0;i<n;i++)
#define FAST           ios_base::sync_with_stdio(false); cin.tie(NULL);
#define NN             998244353
#define mem1(vis)     memset(vis,-1,sizeof(vis))
#define mem0(vis)     memset(vis,0,sizeof(vis));
#define DECIMAL(n)  std::cout << std::fixed;std::cout << std::setprecision(n);
#define make make_pair
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define sz(a) (int)a.size()
#define loop(i,a,b) for(ll i=a;i<=b;i++)

/*
CHAR_BIT       = number of bits in a char
CHAR_MIN/MAX   = min/max value for a char
INT_MIN/MAX    = min/max value for an int
LLONG_MIN/MAX  = min/max value for a long long
*/

//std::ifstream in("input.txt");
//std::ofstream out("output.txt");
ll prime(ll n)
{
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        return 0;
    }
    return 1;
}
/*
ll find(ll n)
{
    while(1)
    {
        if(n==parent[n])
        return n;
        else
        n=parent[n];
    }
}
void union(ll a,ll b)
{
    ll x=find(a);
    ll y=find(b);
    if(x==y)
    return ;
    else
    parent[x]=y;
}
//ll dp[500001][500001];

ll power(ll x,ll y,ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {

        if (y & 1)
            res = (res*x) % p;

        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll modInverse(ll n,ll p)
{
   return power(n, p-2, p);
}
*/

//ll cnt;
/*void bfs(ll x,ll vis[],vector<ll> v[])
{
    for(auto i:v[x])
    {
        if(!vis[i])
        {
            vis[i]=1;
            cnt++;
            bfs(i,vis,v);
        }
    }
}*/
ll getsum(ll tree[],ll index)
{
    index++;
    ll sum=0;
    while(index>0)
    {
        sum+=tree[index];
        index-=(index&-index);
    }
    return sum;
}
void update(ll tree[],ll index,ll value,ll n)
{
    index++;
    while(index<=n)
    {
        tree[index]+=value;
        index+=(index&-index);
    }
}
ll *buildtree(ll n,ll a[])
{
    ll *tree=new ll[n+1];
    for(ll i=0;i<=n;i++)
    tree[i]=0;
    for(ll i=0;i<n;i++)
    {
        update(tree,i,a[i],n);
    }
    return tree;
}
int main()
{
    FAST;
    ll n,q,x;
    cin>>n>>q;
    ll a[n];
    mem0(a);
    loop(i,0,n-1)
    {
        cin>>x;
        x--;
        a[x]++;
    }
    ll *tree=buildtree(n,a);
    while(q--)
    {
        cin>>x;
        if(x>0)
        {
            update(tree,x-1,1,n);
        }
        else
        {
            ll l=0;
            x*=-1;
            ll r=n-1;
            while(r-l>1)
            {
                ll mid=(l+r)/2;
                ll y=getsum(tree,mid);
                if(y>x)
                {
                    r=mid;
                }
                else if(y<x)
                {
                    l=mid;
                }
                else
                {
                    l=mid;
                    r=mid;
                    break;
                }

            }
            if(getsum(tree,l)>=x)
            {
                r=l;
            }
            //cout<<r<<" "<<getsum(tree,r)<<endl;
            update(tree,r,-1,n);
        }
    }
    if(getsum(tree,n-1)==0)
    cout<<0;
    else
    {
    for(ll i=0;i<n;i++)
    {

        //cout<<getsum(tree,i)<<" ";
        if(getsum(tree,i)>0)
        {cout<<i+1<<endl;
        break;}
    }

    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int getSum(int BITree[], int index)
{
	int sum = 0;
    index = index + 1;
    while (index>0)
	{
		sum += BITree[index];
		index -= index & (-index);
	}
	return sum;
}
void updateBIT(int BITree[], int n, int index, int val)
{
	index = index + 1;
     while (index <= n)
	{
	BITree[index] += val;
    index += index & (-index);
	}
}
int *constructBITree(int arr[], int n)
{
	int *BITree = new int[n+1];
	for (int i=1; i<=n; i++)
		BITree[i] = 0;
	for (int i=0; i<n; i++)
		updateBIT(BITree, n, i, arr[i]);
	return BITree;
}
int main()
{
    int n,q,x;
    cin>>n>>q;
    int a[n];
    memset(a,0,sizeof(a));
    for(int i=0;i<n;i++)
    {
        cin>>x;
        a[x-1]++;
    }

	int *BITree = constructBITree(a, n);
	while(q--)
	{
	    int x;
	    cin>>x;
	    if(x>0)
	    {
	        updateBIT(BITree,n,x-1,1);
	    }
	    else
	    {
	        int z=abs(x);
            int l=0,r=n-1;
            while(r-l>1)
            {
                int mid=(l+r)/2;
                int y=getSum(BITree,mid);
                if(y>z)
                {
                    r=mid;
                }
                else if(y<z)
                {
                    l=mid;
                }
                else
                {
                    l=mid;
                    r=mid;
                    break;
                }
            }

            if(getSum(BITree, l)>=z)
            {
                updateBIT(BITree,n,l,-1);
            }
            else
            {
                updateBIT(BITree,n,r,-1);
            }

	    }
	}
    if(getSum(BITree,n-1)==0)
    {cout<<0;
    return 0;}
    for(int i=0;i<n;i++)
    {
        if(getSum(BITree,i)>0)
        {
            cout<<i+1;
            return 0;
        }
    }
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define FAST           ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
int getSum(int BITree[], int index)
{
	int sum = 0;
    index = index + 1;
    while (index>0)
	{
		sum += BITree[index];
		index -= index & (-index);
	}
	return sum;
}
void updateBIT(int BITree[], int n, int index, int val)
{
	index = index + 1;
     while (index <= n)
	{
	BITree[index] += val;
    index += index & (-index);
	}
}
int *constructBITree(int arr[], int n)
{
	int *BITree = new int[n+1];
	for (int i=1; i<=n; i++)
		BITree[i] = 0;
	for (int i=0; i<n; i++)
		updateBIT(BITree, n, i, arr[i]);
	return BITree;
}
int main()
{
    FAST;
    int n,q,x;
    cin>>n>>q;
    int a[n+1];
    memset(a,0,sizeof(a));
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        a[x]++;
    }

	int *BITree = constructBITree(a, n);
	while(q--)
	{
	    int x;
	    cin>>x;
	    if(x>0)
	    {
	        updateBIT(BITree,n+1,x,1);
	    }
	    else
	    {
	        int z=abs(x);
            int l=1,r=n;
            while(r-l>1)
            {
                int mid=(l+r)/2;
                int y=getSum(BITree,mid);
                if(y>z)
                {
                    r=mid;
                }
                else if(y<z)
                {
                    l=mid;
                }
                else
                {
                    l=mid;
                    r=mid;
                    break;
                }
            }

            if(getSum(BITree, l)>=z)
            {
                updateBIT(BITree,n+1,l,-1);
            }
            else
            {
                updateBIT(BITree,n,r,-1);
            }

	    }
	}
    if(getSum(BITree,n)==0)
    {cout<<0;
    return 0;}
    for(int i=1;i<=n;i++)
    {
        if(getSum(BITree,i)>0)
        {
            cout<<i;
            return 0;
        }
    }
	return 0;
}


/* NEVER GIVE UP */
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define vi             vector<ll>
#define mi             map<ll,ll>
#define pi             pair<ll,ll>
#define si             set<ll>
#define endl            "\n"
#define N              1000000007
#define PI              3.1415926535897932384
#define inf             1000000000000000005
#define ll              long long
#define f               first
#define s              second
#define pb             push_back
#define fr(n)          for(ll i=0;i<n;i++)
#define FAST           ios_base::sync_with_stdio(false); cin.tie(NULL);
#define NN             998244353
#define mem1(vis)     memset(vis,-1,sizeof(vis))
#define mem0(vis)     memset(vis,0,sizeof(vis));
#define DECIMAL(n)  std::cout << std::fixed;std::cout << std::setprecision(n);
#define make make_pair
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define sz(a) (int)a.size()
#define loop(i,a,b) for(ll i=a;i<=b;i++)

/*
CHAR_BIT       = number of bits in a char
CHAR_MIN/MAX   = min/max value for a char
INT_MIN/MAX    = min/max value for an int
LLONG_MIN/MAX  = min/max value for a long long
*/

//std::ifstream in("input.txt");
//std::ofstream out("output.txt");
/*ll prime(ll n)
{
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        return 0;
    }
    return 1;
}

ll find(ll n)
{
    while(1)
    {
        if(n==parent[n])
        return n;
        else
        n=parent[n];
    }
}
void union(ll a,ll b)
{
    ll x=find(a);
    ll y=find(b);
    if(x==y)
    return ;
    else
    parent[x]=y;
}
//ll dp[500001][500001];

ll power(ll x,ll y,ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {

        if (y & 1)
            res = (res*x) % p;

        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll modInverse(ll n,ll p)
{
   return power(n, p-2, p);
}
*/
const ll Z=100005;
ll tree[(ll)Z<<2];

ll query(ll *tree,ll index,ll s,ll e,ll qs,ll qe)
{
    // no overlap
    if(qs>e||s>qe)
    return 0;
    if(qe>=e&&s>=qs)// complete overlap
    {
        return tree[index];
    }
    ll mid=(s+e)/2;
    ll left=query(tree,2*index,s,mid,qs,qe);
    ll right=query(tree,2*index+1,mid+1,e,qs,qe);
    return left+right;
}
void updatenode(ll *tree,ll index,ll s,ll e,ll i,ll val)
{
    if(i>e||i<s)
    return ;
    if(s==e)
    {
        tree[index]+=val;
        return ;
    }
    ll mid=(s+e)/2;
    updatenode(tree,2*index,s,mid,i,val);
    updatenode(tree,2*index+1,mid+1,e,i,val);
    tree[index]=tree[2*index]+tree[2*index+1];
    return ;
}

int main()
{
    ll n,q,x;
    cin>>n>>q;
    ll a[n+1];
    mem0(a);
    loop(i,1,n)//={1,2,3,4,5,60};
    {
        cin>>x;
        updatenode(tree,1,1,n,x,1);
    }
    ll index=1;
    ll start=1;
    ll end=n;
    //cout<<query(tree,1,1,n,1,n)<<endl;
    while(q--)
    {
        cin>>x;
        if(x>0)
        {
            updatenode(tree,1,1,n,x,1);
        }
        else
        {
            ll z=abs(x);
            ll l=1,r=n;

            while(r-l>1)
            {
                ll mid=(l+r)/2;
                ll y=query(tree,1,1,n,l,mid);
                if(y>z)
                {
                    r=mid;
                }
                else if(y<z)
                {
                    l=mid;
                }
                else
                {
                    l=mid;
                    r=mid;
                    break;
                }

            }

            if(query(tree,1,1,n,1,l)>=z)
            {
                updatenode(tree,1,1,n,l,-1);
            }
            else
            {
                updatenode(tree,1,1,n,r,-1);
            }
        }
     }

    // cout<<endl;
     for(ll i=1;i<=n;i++)
     {
         ll y=query(tree,1,1,n,1,i);
         if(y>0)
         {
             cout<<i;
             return 0;
         }
     }
     cout<<0;
    return 0;
}


#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

const int N = 1e6 + 5;
int n, tree[N * 4];
int arr[N];
void build(int idx, int leftmost, int rightmost) {
    if(leftmost == rightmost) {
        tree[idx] = arr[leftmost];
    } else {
        int mid = (leftmost + rightmost) / 2;
        build(idx * 2, leftmost, mid);
        build(idx * 2 + 1, mid + 1, rightmost);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int sum(int idx, int leftmost, int rightmost, int l, int r) {
    if(rightmost < l || leftmost > r)return 0;
    if(l <= leftmost && r >= rightmost)return tree[idx];

    int mid = (leftmost + rightmost) / 2;
    int lSum = sum(idx * 2, leftmost, mid, l, r);
    int rSum = sum(idx * 2 + 1, mid + 1, rightmost, l, r);
    return lSum + rSum;
}

void update(int idx, int leftmost, int rightmost, int pos, int val) {
    if(leftmost == rightmost) {
        tree[idx] += val;
    } else {
        int mid = (leftmost + rightmost) / 2;
        if(pos <= mid)
            update(idx * 2, leftmost, mid, pos, val);
        else
            update(idx * 2 + 1, mid + 1, rightmost, pos, val);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int32_t main() {

    fast
    int q;
    cin >> n >> q;

    for(int i = 0; i < n; i++) {
        cin >> arr[i];
        update(1, 0, n - 1, arr[i], 1);
    }
    // build(1,0,n-1);
    int value;
    while(q--) {
        cin >> value;

        if(value < 0) {
            value *= -1;
            int left = 0;
            int right = N - 1;
            int ans = 0;
            while(left <= right) {
                int mid = (left + right) / 2;
                if(sum(1, 0, n - 1, 1, mid) >= value) {
                    ans = mid;
                    right = mid - 1;
                } else {
                    left = mid + 1;
                }
            }
            update(1, 0, n - 1, ans, -1);
        } else {
            update(1, 0, n - 1, value, 1);
        }
    }

    for(int i = 1; i <= n; i++) {
        if(sum(1, 0, n - 1, 0, i) != 0) {
            cout << i  << endl;
            return 0;
        }
    }
    cout << 0 << endl;

    return 0;
}


#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
using namespace std;

const int N=1e6+5;

int bit[N];

int sum(int i){
    int s=0;
    while(i>0){
        s+=bit[i];
        i=i-(i&(-i));
    }
    return s;
}
void update(int i,int add){
    while(i<N){
        bit[i]+=add;
        i=i+(i&(-i));
    }
}

int32_t main(){

    fast
    int n,q;
    int temp;
    cin>>n>>q;
    for(int i=0;i<n;i++){
        cin>>temp;
        update(temp,1);
    }
    // for(int i=1;i<=n;i++){
    //     cout<<bit[i]<<" ";
    // }
    // cout<<endl;
    while(q--){
        int x;
        cin>>x;
        if(x>0){
            update(x,1);
        }
        else{
            x*=-1;
            int low=0;int high=N-1;
            int ans=0,mid;
            while(low<=high){
                mid=low+(high-low)/2;
                if(sum(mid)<x){
                    low=mid+1;
                }
                else{
                    ans=mid;
                    high=mid-1;
                }
                //cout<<"ans is "<<ans<<endl;
            }
            //cout<<"x is "<<x<<" ans is "<<ans<<endl;
            update(ans,-1);
        }
    }
    if(sum(N)==0){
        cout<<0<<endl;
        return 0;
    }
    for(int i=1;i<=n;i++){
        if(sum(i)>0){

            cout<<i<<endl;
            return 0;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long
#define endl "\n"
using namespace std;

const int N = 1e6 + 5;
int n, tree[N * 4];
int arr[N];
void build(int idx, int leftmost, int rightmost) {
    if(leftmost == rightmost) {
        tree[idx] = arr[leftmost];
    } else {
        int mid = (leftmost + rightmost) / 2;
        build(idx * 2, leftmost, mid);
        build(idx * 2 + 1, mid + 1, rightmost);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int sum(int idx, int leftmost, int rightmost, int l, int r) {
    if(rightmost < l || leftmost > r)return 0;
    if(l <= leftmost && r >= rightmost)return tree[idx];

    int mid = (leftmost + rightmost) / 2;
    int lSum = sum(idx * 2, leftmost, mid, l, r);
    int rSum = sum(idx * 2 + 1, mid + 1, rightmost, l, r);
    return lSum + rSum;
}

void update(int idx, int leftmost, int rightmost, int pos, int val) {
    if(leftmost == rightmost) {
        tree[idx] += val;
    } else {
        int mid = (leftmost + rightmost) / 2;
        if(pos <= mid)
            update(idx * 2, leftmost, mid, pos, val);
        else
            update(idx * 2 + 1, mid + 1, rightmost, pos, val);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int query(int idx,int leftmost,int rightmost,int p){
    if(leftmost==rightmost){
        return leftmost;
    }
    int mid=(leftmost+rightmost)/2;
    if(tree[idx*2]>=p){
        return query(idx*2,leftmost,mid,p);
    }
    else{
        return query(idx*2+1,mid+1,rightmost,p-tree[idx*2]);
    }
}

int32_t main() {

    fast
    int q;
    cin >> n >> q;

    for(int i = 0; i < n; i++) {
        cin >> arr[i];
        update(1, 0, n - 1, arr[i], 1);
    }
    int maxi=*max_element(arr,arr+n);
    // build(1,0,n-1);
    int value;
    while(q--) {
        cin >> value;

        if(value < 0) {
            value *= -1;
            int pos = query(1, 0, n - 1, value);
            update(1, 0, n - 1, pos, -1);
        } else {
            maxi=max(maxi,value);
            update(1, 0, n - 1, value, 1);
        }
    }

    for(int i = 1; i <=maxi ; i++) {
        if(sum(1, 0, n - 1, 0, i) != 0) {
            cout << i  << endl;
            return 0;
        }
    }
    cout << 0 << endl;

    return 0;
}


#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define endl "\n"
#define ll long long
#define int long long
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;
ost st;

int32_t main(){

    fast
    int n,q;
    cin>>n>>q;
    int temp;
    for(int i=0;i<n;i++){
        cin>>temp;
        st.insert(temp);
    }
    while(q--){
        cin>>temp;
        if(temp<0){
            temp++;
            temp*=-1;
            st.erase(st.find_by_order(temp));
        }
        else{
            st.insert(temp);
        }
    }
    if(st.size()!=0){
        cout<<(*st.begin())<<endl;
    }
    else{
        cout<<0<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

const int N = 1e6 + 5;
int n, tree[N * 4];
int arr[N];
void build(int idx, int leftmost, int rightmost) {
    if(leftmost == rightmost) {
        tree[idx] = arr[leftmost];
    } else {
        int mid = (leftmost + rightmost) / 2;
        build(idx * 2, leftmost, mid);
        build(idx * 2 + 1, mid + 1, rightmost);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int sum(int idx, int leftmost, int rightmost, int l, int r) {
    if(rightmost < l || leftmost > r)return 0;
    if(l <= leftmost && r >= rightmost)return tree[idx];

    int mid = (leftmost + rightmost) / 2;
    int lSum = sum(idx * 2, leftmost, mid, l, r);
    int rSum = sum(idx * 2 + 1, mid + 1, rightmost, l, r);
    return lSum + rSum;
}

void update(int idx, int leftmost, int rightmost, int pos, int val) {
    if(leftmost == rightmost) {
        tree[idx] += val;
    } else {
        int mid = (leftmost + rightmost) / 2;
        if(pos <= mid)
            update(idx * 2, leftmost, mid, pos, val);
        else
            update(idx * 2 + 1, mid + 1, rightmost, pos, val);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int query(int idx,int leftmost,int rightmost,int p){
    if(leftmost==rightmost){
        return leftmost;
    }
    int mid=(leftmost+rightmost)/2;
    if(tree[idx*2]>=p){
        return query(idx*2,leftmost,mid,p);
    }
    else{
        return query(idx*2+1,mid+1,rightmost,p-tree[idx*2]);
    }
}

int32_t main() {

    fast
    int q;
    cin >> n >> q;

    for(int i = 0; i < n; i++) {
        cin >> arr[i];
        update(1, 0, n - 1, arr[i], 1);
    }
    int maxi=*max_element(arr,arr+n);
    // build(1,0,n-1);
    int value;
    while(q--) {
        cin >> value;

        if(value < 0) {
            value *= -1;
            int pos = query(1, 0, n - 1, value);
            update(1, 0, n - 1, pos, -1);
        } else {
            maxi=max(maxi,value);
            update(1, 0, n - 1, value, 1);
        }
    }

    for(int i = 1; i <=maxi ; i++) {
        if(sum(1, 0, n - 1, 0, i) != 0) {
            cout << i  << endl;
            return 0;
        }
    }
    cout << 0 << endl;

    return 0;
}


#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// #define int long long
#define endl "\n"
using namespace std;

const int N = 1e6 + 5;
int n, tree[N * 4];
int arr[N];
void build(int idx, int leftmost, int rightmost) {
    if(leftmost == rightmost) {
        tree[idx] = arr[leftmost];
    } else {
        int mid = (leftmost + rightmost) / 2;
        build(idx * 2, leftmost, mid);
        build(idx * 2 + 1, mid + 1, rightmost);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int sum(int idx, int leftmost, int rightmost, int l, int r) {
    if(rightmost < l || leftmost > r)return 0;
    if(l <= leftmost && r >= rightmost)return tree[idx];

    int mid = (leftmost + rightmost) / 2;
    int lSum = sum(idx * 2, leftmost, mid, l, r);
    int rSum = sum(idx * 2 + 1, mid + 1, rightmost, l, r);
    return lSum + rSum;
}

void update(int idx, int leftmost, int rightmost, int pos, int val) {
    if(leftmost == rightmost) {
        tree[idx] += val;
    } else {
        int mid = (leftmost + rightmost) / 2;
        if(pos <= mid)
            update(idx * 2, leftmost, mid, pos, val);
        else
            update(idx * 2 + 1, mid + 1, rightmost, pos, val);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int query(int idx,int leftmost,int rightmost,int p){
    if(leftmost==rightmost){
        return leftmost;
    }
    int mid=(leftmost+rightmost)/2;
    if(tree[idx*2]>=p){
        return query(idx*2,leftmost,mid,p);
    }
    else{
        return query(idx*2+1,mid+1,rightmost,p-tree[idx*2]);
    }
}

int32_t main() {

    fast
    int q;
    cin >> n >> q;

    for(int i = 0; i < n; i++) {
        cin >> arr[i];
        update(1, 0, n - 1, arr[i], 1);
    }
    int maxi=*max_element(arr,arr+n);
    // build(1,0,n-1);
    int value;
    while(q--) {
        cin >> value;

        if(value < 0) {
            value *= -1;
            int pos = query(1, 0, n - 1, value);
            update(1, 0, n - 1, pos, -1);
        } else {
            update(1, 0, n - 1, value, 1);
        }
    }

    for(int i = 1; i <=maxi ; i++) {
        if(sum(1, 0, n - 1, 0, i) != 0) {
            cout << i  << endl;
            return 0;
        }
    }
    cout << 0 << endl;

    return 0;
}


#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// #define int long long
#define endl "\n"
using namespace std;

const int N = 1e6 + 5;
int n, tree[N * 4];
int arr[N];
void build(int idx, int leftmost, int rightmost) {
    if(leftmost == rightmost) {
        tree[idx] = arr[leftmost];
    } else {
        int mid = (leftmost + rightmost) / 2;
        build(idx * 2, leftmost, mid);
        build(idx * 2 + 1, mid + 1, rightmost);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int sum(int idx, int leftmost, int rightmost, int l, int r) {
    if(rightmost < l || leftmost > r)return 0;
    if(l <= leftmost && r >= rightmost)return tree[idx];

    int mid = (leftmost + rightmost) / 2;
    int lSum = sum(idx * 2, leftmost, mid, l, r);
    int rSum = sum(idx * 2 + 1, mid + 1, rightmost, l, r);
    return lSum + rSum;
}

void update(int idx, int leftmost, int rightmost, int pos, int val) {
    if(leftmost == rightmost) {
        tree[idx] += val;
    } else {
        int mid = (leftmost + rightmost) / 2;
        if(pos <= mid)
            update(idx * 2, leftmost, mid, pos, val);
        else
            update(idx * 2 + 1, mid + 1, rightmost, pos, val);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int32_t main() {

    fast
    int q;
    cin >> n >> q;

    int value;
    for(int i = 0; i < n; i++) {
        cin >> value;
        arr[value]++;
        // update(1, 0, n - 1, arr[i], 1);
    }

    build(1, 1, n );
    while(q--) {
        cin >> value;

        if(value < 0) {
            value *= -1;
            int left = 0;
            int right = N - 1;
            int ans = 0;
            while(left <= right) {
                int mid = (left + right) / 2;
                if(sum(1, 0, n - 1, 1, mid) >= value) {
                    ans = mid;
                    right = mid - 1;
                } else {
                    left = mid + 1;
                }
            }
            update(1, 0, n - 1, ans, -1);
        } else {
            update(1, 0, n - 1, value, 1);
        }
    }

    for(int i = 1; i <= n; i++) {
        if(sum(1, 0, n - 1, 0, i) != 0) {
            cout << i  << endl;
            return 0;
        }
    }
    cout << 0 << endl;

    return 0;
}


#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// #define int long long
#define endl "\n"
using namespace std;

const int N = 1e6 + 5;
int n, tree[N * 4];
int arr[N];
void build(int idx, int leftmost, int rightmost) {
    if(leftmost == rightmost) {
        tree[idx] = arr[leftmost];
    } else {
        int mid = (leftmost + rightmost) / 2;
        build(idx * 2, leftmost, mid);
        build(idx * 2 + 1, mid + 1, rightmost);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int sum(int idx, int leftmost, int rightmost, int l, int r) {
    if(rightmost < l || leftmost > r)return 0;
    if(l <= leftmost && r >= rightmost)return tree[idx];

    int mid = (leftmost + rightmost) / 2;
    int lSum = sum(idx * 2, leftmost, mid, l, r);
    int rSum = sum(idx * 2 + 1, mid + 1, rightmost, l, r);
    return lSum + rSum;
}

void update(int idx, int leftmost, int rightmost, int pos, int val) {
    if(leftmost == rightmost) {
        tree[idx] += val;
    } else {
        int mid = (leftmost + rightmost) / 2;
        if(pos <= mid)
            update(idx * 2, leftmost, mid, pos, val);
        else
            update(idx * 2 + 1, mid + 1, rightmost, pos, val);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int query(int idx,int leftmost,int rightmost,int p){
    if(leftmost==rightmost){
        return leftmost;
    }
    int mid=(leftmost+rightmost)/2;
    if(tree[idx*2]>=p){
        return query(idx*2,leftmost,mid,p);
    }
    else{
        return query(idx*2+1,mid+1,rightmost,p-tree[idx*2]);
    }
}

int32_t main() {

    fast
    int q;
    cin >> n >> q;

    for(int i = 0; i < n; i++) {
        cin >> arr[i];
        update(1, 0, n - 1, arr[i], 1);
    }
    // build(1,0,n-1);
    int value;
    while(q--) {
        cin >> value;

        if(value < 0) {
            value *= -1;
            int pos = query(1, 0, n - 1, value);
            update(1, 0, n - 1, pos, -1);
        } else {
            update(1, 0, n - 1, value, 1);
        }
    }

    for(int i = 0; i < n; i++) {
        if(sum(1, 0, n - 1, 0, i) != 0) {
            cout << i +1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;

    return 0;
}


#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

const int N=1e6+6;
int bit[N];

int sum(int i){
    int s=0;
    while(i>0){
        s+=bit[i];
        i=i-(i&(-i));
    }
    return s;
}
void update(int i,int add){
    while(i<N){
        bit[i]+=add;
        i=i+(i&(-i));
    }
}

int32_t main() {

    fast
    int n,q;
    cin>>n>>q;

    int value;
    for(int i=0;i<n;i++){
        cin>>value;
        update(value,1);
    }

    while(q--){
        cin>>value;
        if(value<0){
            value*=-1;
            int left=0;
            int right=N-1;
            int ans=0;
            while(left<=right){
                int mid=(left+right)/2;
                if(sum(mid)>=value){
                    ans=mid;
                    right=mid-1;
                }
                else{
                    left=mid+1;
                }
            }
            update(ans,-1);
        }
        else{
            update(value,1);
        }
    }
    if(sum(N-1)==0){
        cout<<0<<endl;
    }
    else{
        for(int i=0;i<n;i++){
            if(sum(i)>0){
                cout<<i<<endl;
                break;
            }
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long
#define endl "\n"
using namespace std;

const int N = 1e6 + 5;
int n, tree[N * 4];
int arr[N];
void build(int idx, int leftmost, int rightmost) {
    if(leftmost == rightmost) {
        tree[idx] = arr[leftmost];
    } else {
        int mid = (leftmost + rightmost) / 2;
        build(idx * 2, leftmost, mid);
        build(idx * 2 + 1, mid + 1, rightmost);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

// int sum(int idx, int leftmost, int rightmost, int l, int r) {
//     if(rightmost < l || leftmost > r)return 0;
//     if(l <= leftmost && r >= rightmost)return tree[idx];

//     int mid = (leftmost + rightmost) / 2;
//     int lSum = sum(idx * 2, leftmost, mid, l, r);
//     int rSum = sum(idx * 2 + 1, mid + 1, rightmost, l, r);
//     return lSum + rSum;
// }
int sum(int v, int tl, int tr, int l, int r) {
    if (l > r)
        return 0;
    if (l == tl && r == tr) {
        return tree[v];
    }
    int tm = (tl + tr) / 2;
    return sum(v*2, tl, tm, l, min(r, tm))
           + sum(v*2+1, tm+1, tr, max(l, tm+1), r);
}

void update(int idx, int leftmost, int rightmost, int pos, int val) {
    if(leftmost == rightmost) {
        tree[idx] += val;
    } else {
        int mid = (leftmost + rightmost) / 2;
        if(pos <= mid)
            update(idx * 2, leftmost, mid, pos, val);
        else
            update(idx * 2 + 1, mid + 1, rightmost, pos, val);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int query(int idx,int leftmost,int rightmost,int p){
    if(leftmost==rightmost){
        return leftmost;
    }
    int mid=(leftmost+rightmost)/2;
    if(tree[idx*2]>=p){
        return query(idx*2,leftmost,mid,p);
    }
    else{
        return query(idx*2+1,mid+1,rightmost,p-tree[idx*2]);
    }
}

int32_t main() {

    fast
    int q;
    cin >> n >> q;

    for(int i = 0; i < n; i++) {
        cin >> arr[i];
        update(1, 0, n - 1, arr[i], 1);
    }
    int maxi=*max_element(arr,arr+n);
    // build(1,0,n-1);
    int value;
    while(q--) {
        cin >> value;

        if(value < 0) {
            value *= -1;
            int pos = query(1, 0, n - 1, value);
            update(1, 0, n - 1, pos, -1);
        } else {
            maxi=max(maxi,value);
            update(1, 0, n - 1, value, 1);
        }
    }

    for(int i = 1; i <=n ; i++) {
        if(sum(1, 0, n - 1, 1 , i) != 0) {
            cout << i  << endl;
            return 0;
        }
    }
    cout << 0 << endl;

    return 0;
}


#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// #define int long long
#define endl "\n"
using namespace std;

const int N = 1e6 + 5;
int n, tree[N * 4];
int arr[N];
void build(int idx, int leftmost, int rightmost) {
    if(leftmost == rightmost) {
        tree[idx] = arr[leftmost];
    } else {
        int mid = (leftmost + rightmost) / 2;
        build(idx * 2, leftmost, mid);
        build(idx * 2 + 1, mid + 1, rightmost);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int sum(int idx, int leftmost, int rightmost, int l, int r) {
    if(rightmost < l || leftmost > r)return 0;
    if(l <= leftmost && r >= rightmost)return tree[idx];

    int mid = (leftmost + rightmost) / 2;
    int lSum = sum(idx * 2, leftmost, mid, l, r);
    int rSum = sum(idx * 2 + 1, mid + 1, rightmost, l, r);
    return lSum + rSum;
}

void update(int idx, int leftmost, int rightmost, int pos, int val) {
    if(leftmost == rightmost) {
        tree[idx] += val;
    } else {
        int mid = (leftmost + rightmost) / 2;
        if(pos <= mid)
            update(idx * 2, leftmost, mid, pos, val);
        else
            update(idx * 2 + 1, mid + 1, rightmost, pos, val);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int query(int idx,int leftmost,int rightmost,int p){
    if(leftmost==rightmost){
        return leftmost;
    }
    int mid=(leftmost+rightmost)/2;
    if(tree[idx*2]>=p){
        return query(idx*2,leftmost,mid,p);
    }
    else{
        return query(idx*2+1,mid+1,rightmost,p-tree[idx*2]);
    }
}

int32_t main() {

    fast
    int q;
    cin >> n >> q;

    for(int i = 0; i < n; i++) {
        cin >> arr[i];
        update(1, 0, n - 1, arr[i], 1);
    }
    int maxi=*max_element(arr,arr+n);
    // build(1,0,n-1);
    int value;
    while(q--) {
        cin >> value;

        if(value < 0) {
            value *= -1;
            int pos = query(1, 0, n - 1, value);
            update(1, 0, n - 1, pos, -1);
        } else {
            maxi=max(maxi,value);
            update(1, 0, n - 1, value, 1);
        }
    }

    for(int i = 1; i <=maxi ; i++) {
        if(sum(1, 0, n - 1, 0, i) != 0) {
            cout << i  << endl;
            return 0;
        }
    }
    cout << 0 << endl;

    return 0;
}


#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// #define int long long
#define endl "\n"
using namespace std;

const int N = 1e6 + 5;
int n, tree[N * 4];
int arr[N];
void build(int idx, int leftmost, int rightmost) {
    if(leftmost == rightmost) {
        tree[idx] = arr[leftmost];
    } else {
        int mid = (leftmost + rightmost) / 2;
        build(idx * 2, leftmost, mid);
        build(idx * 2 + 1, mid + 1, rightmost);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int sum(int idx, int leftmost, int rightmost, int l, int r) {
    if(rightmost < l || leftmost > r)return 0;
    if(l <= leftmost && r >= rightmost)return tree[idx];

    int mid = (leftmost + rightmost) / 2;
    int lSum = sum(idx * 2, leftmost, mid, l, r);
    int rSum = sum(idx * 2 + 1, mid + 1, rightmost, l, r);
    return lSum + rSum;
}

void update(int idx, int leftmost, int rightmost, int pos, int val) {
    if(leftmost == rightmost) {
        tree[idx] += val;
    } else {
        int mid = (leftmost + rightmost) / 2;
        if(pos <= mid)
            update(idx * 2, leftmost, mid, pos, val);
        else
            update(idx * 2 + 1, mid + 1, rightmost, pos, val);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int query(int idx,int leftmost,int rightmost,int p){
    if(leftmost==rightmost){
        return leftmost;
    }
    int mid=(leftmost+rightmost)/2;
    if(tree[idx*2]>=p){
        return query(idx*2,leftmost,mid,p);
    }
    else{
        return query(idx*2+1,mid+1,rightmost,p-tree[idx*2]);
    }
}

int32_t main() {

    fast
    int q;
    cin >> n >> q;

    for(int i = 0; i < n; i++) {
        cin >> arr[i];
        update(1, 0, n - 1, arr[i], 1);
    }
    // build(1,0,n-1);
    int value;
    while(q--) {
        cin >> value;

        if(value < 0) {
            value *= -1;
            int pos = query(1, 0, n - 1, value);
            update(1, 0, n - 1, pos, -1);
        } else {
            update(1, 0, n - 1, value, 1);
        }
    }

    for(int i = 1; i <= n; i++) {
        if(sum(1, 0, n - 1, 0, i) != 0) {
            cout << i  << endl;
            return 0;
        }
    }
    cout << 0 << endl;

    return 0;
}


#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// #define int long
#define endl "\n"
using namespace std;

const int N = 1e6 + 5;
int n, tree[N * 4];
int arr[N];
void build(int idx, int leftmost, int rightmost) {
    if(leftmost == rightmost) {
        tree[idx] = arr[leftmost];
    } else {
        int mid = (leftmost + rightmost) / 2;
        build(idx * 2, leftmost, mid);
        build(idx * 2 + 1, mid + 1, rightmost);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int sum(int idx, int leftmost, int rightmost, int l, int r) {
    if(rightmost < l || leftmost > r)return 0;
    if(l <= leftmost && r >= rightmost)return tree[idx];

    int mid = (leftmost + rightmost) / 2;
    int lSum = sum(idx * 2, leftmost, mid, l, r);
    int rSum = sum(idx * 2 + 1, mid + 1, rightmost, l, r);
    return lSum + rSum;
}

void update(int idx, int leftmost, int rightmost, int pos, int val) {
    if(leftmost == rightmost) {
        tree[idx] += val;
    } else {
        int mid = (leftmost + rightmost) / 2;
        if(pos <= mid)
            update(idx * 2, leftmost, mid, pos, val);
        else
            update(idx * 2 + 1, mid + 1, rightmost, pos, val);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int query(int idx, int leftmost, int rightmost, int p) {
    if(leftmost == rightmost) {
        return leftmost;
    }
    int mid = (leftmost + rightmost) / 2;
    if(tree[idx * 2] >= p) {
        return query(idx * 2, leftmost, mid, p);
    } else {
        return query(idx * 2 + 1, mid + 1, rightmost, p - tree[idx * 2]);
    }
}

int32_t main() {

    fast
    int q;
    cin >> n >> q;

    for(int i = 0; i < n; i++) {
        cin >> arr[i];
        update(1, 0, n - 1, arr[i] - 1, 1);
    }
    int value;
    while(q--) {
        cin >> value;

        if(value < 0) {
            value *= -1;
            int pos = query(1, 0, n - 1, value);
            update(1, 0, n - 1, pos, -1);
        } else {
            update(1, 0, n - 1, value - 1, 1);
        }
    }

    for(int i = 0 ; i < n ; i++) {
        if(sum(1, 0, n - 1, 0, i) != 0) {
            cout << i + 1  << endl;
            return 0;
        }
    }
    cout << 0 << endl;

    return 0;
}


#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long
#define endl "\n"
using namespace std;

const int N = 1e6 + 5;
int n, tree[N * 4];
int arr[N];
void build(int idx, int leftmost, int rightmost) {
    if(leftmost == rightmost) {
        tree[idx] = arr[leftmost];
    } else {
        int mid = (leftmost + rightmost) / 2;
        build(idx * 2, leftmost, mid);
        build(idx * 2 + 1, mid + 1, rightmost);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int sum(int idx, int leftmost, int rightmost, int l, int r) {
    if(rightmost < l || leftmost > r)return 0;
    if(l <= leftmost && r >= rightmost)return tree[idx];

    int mid = (leftmost + rightmost) / 2;
    int lSum = sum(idx * 2, leftmost, mid, l, r);
    int rSum = sum(idx * 2 + 1, mid + 1, rightmost, l, r);
    return lSum + rSum;
}

void update(int idx, int leftmost, int rightmost, int pos, int val) {
    if(leftmost == rightmost) {
        tree[idx] += val;
    } else {
        int mid = (leftmost + rightmost) / 2;
        if(pos <= mid)
            update(idx * 2, leftmost, mid, pos, val);
        else
            update(idx * 2 + 1, mid + 1, rightmost, pos, val);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int query(int idx,int leftmost,int rightmost,int p){
    if(leftmost==rightmost){
        return leftmost;
    }
    int mid=(leftmost+rightmost)/2;
    if(tree[idx*2]>=p){
        return query(idx*2,leftmost,mid,p);
    }
    else{
        return query(idx*2+1,mid+1,rightmost,p-tree[idx*2]);
    }
}

int32_t main() {

    fast
    int q;
    cin >> n >> q;

    for(int i = 0; i < n; i++) {
        cin >> arr[i];
        update(1, 0, n - 1, arr[i], 1);
    }
    int maxi=*max_element(arr,arr+n);
    // build(1,0,n-1);
    int value;
    while(q--) {
        cin >> value;

        if(value < 0) {
            value *= -1;
            int pos = query(1, 0, n - 1, value);
            update(1, 0, n - 1, pos, -1);
        } else {
            maxi=max(maxi,value);
            update(1, 0, n - 1, value, 1);
        }
    }

    for(int i = 1; i <=n ; i++) {
        if(sum(1, 0, n - 1, i, i) != 0) {
            cout << i  << endl;
            return 0;
        }
    }
    cout << 0 << endl;

    return 0;
}


#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

const int N=1e6+6;
int bit[N];

int sum(int i){
    int s=0;
    while(i>0){
        s+=bit[i];
        i=i-(i&(-i));
    }
    return s;
}
void update(int i,int add){
    while(i<N){
        bit[i]+=add;
        i=i+(i&(-i));
    }
}

int32_t main() {

    fast
    int n,q;
    cin>>n>>q;

    int value;
    for(int i=0;i<n;i++){
        cin>>value;
        update(value,1);
    }

    while(q--){
        cin>>value;
        if(value<0){
            value*=-1;
            int left=0;
            int right=N-1;
            int ans;
            while(left<=right){
                int mid=(left+right)/2;
                if(sum(mid)>value){
                    right=mid-1;
                }
                else{
                    ans=mid;
                    left=mid+1;
                }
            }
            update(ans,-1);
        }
        else{
            update(value,1);
        }
    }
    if(sum(N-1)==0){
        cout<<0<<endl;
    }
    else{
        for(int i=0;i<n;i++){
            if(sum(i)>0){
                cout<<i<<endl;
                break;
            }
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

const int N=1e6+6;
int bit[N];

int sum(int i){
    int s=0;
    while(i>0){
        s+=bit[i];
        i=i-(i&(-i));
    }
    return s;
}
void update(int i,int add){
    while(i<N){
        bit[i]+=add;
        i=i+(i&(-i));
    }
}

int32_t main() {

    fast
    int n,q;
    cin>>n>>q;

    int value;
    for(int i=0;i<n;i++){
        cin>>value;
        update(value,1);
    }

    while(q--){
        cin>>value;
        if(value<0){
            value*=-1;
            int left=0;
            int right=N-1;
            int ans=0;
            while(left<=right){
                int mid=(left+right)/2;
                if(sum(mid)>=value){
                    ans=mid;
                    right=mid-1;
                }
                else{
                    left=mid+1;
                }
            }
            update(ans,-1);
        }
        else{
            update(value,1);
        }
    }
    if(sum(N-1)==0){
        cout<<0<<endl;
    }
    else{
        for(int i=1;i<=n;i++){
            if(sum(i)>0){
                cout<<i<<endl;
                break;
            }
        }
    }

    return 0;
}


#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define int long long
using namespace std;

const int N=1e6+5;

int bit[N];

int sum(int i){
    int s=0;
    while(i>0){
        s+=bit[i];
        i=i-(i&(-i));
    }
    return s;
}
void update(int i,int add){
    while(i<N){
        bit[i]+=add;
        i=i+(i&(-i));
    }
}

int32_t main(){

    fast
    int n,q;
    int temp;
    cin>>n>>q;
    for(int i=0;i<n;i++){
        cin>>temp;
        update(temp,1);
    }
    while(q--){
        int x;
        cin>>x;
        if(x>0){
            update(x,1);
        }
        else{
            x*=-1;
            int low=0;int high=N-1;
            int ans=0,mid;
            while(low<=high){
                mid=low+(high-low)/2;
                if(sum(mid)<x){
                    low=mid+1;
                }
                else{
                    ans=mid;
                    high=mid-1;
                }
            }
            update(ans,-1);
        }
    }

    for(int i=1;i<=n;i++){
        if(sum(i)>0){

            cout<<i<<endl;
            return 0;
        }
    }
    cout<<0<<endl;

    return 0;
}


#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// #define int long long
#define endl "\n"
using namespace std;

const int N = 1e6 + 5;
int n, tree[N * 4];
int arr[N];
void build(int idx, int leftmost, int rightmost) {
    if(leftmost == rightmost) {
        tree[idx] = arr[leftmost];
    } else {
        int mid = (leftmost + rightmost) / 2;
        build(idx * 2, leftmost, mid);
        build(idx * 2 + 1, mid + 1, rightmost);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int sum(int idx, int leftmost, int rightmost, int l, int r) {
    if(rightmost < l || leftmost > r)return 0;
    if(l <= leftmost && r >= rightmost)return tree[idx];

    int mid = (leftmost + rightmost) / 2;
    int lSum = sum(idx * 2, leftmost, mid, l, r);
    int rSum = sum(idx * 2 + 1, mid + 1, rightmost, l, r);
    return lSum + rSum;
}

void update(int idx, int leftmost, int rightmost, int pos, int val) {
    if(leftmost == rightmost) {
        tree[idx] += val;
    } else {
        int mid = (leftmost + rightmost) / 2;
        if(pos <= mid)
            update(idx * 2, leftmost, mid, pos, val);
        else
            update(idx * 2 + 1, mid + 1, rightmost, pos, val);
        tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    }
}

int32_t main() {

    fast
    int q;
    cin >> n >> q;

    for(int i = 0; i < n; i++) {
        cin >> arr[i];
        update(1, 0, n - 1, arr[i], 1);
    }
    // build(1,0,n-1);
    int value;
    while(q--) {
        cin >> value;

        if(value < 0) {
            value *= -1;
            int left = 0;
            int right = N - 1;
            int ans = 0;
            while(left <= right) {
                int mid = (left + right) / 2;
                if(sum(1, 0, n - 1, 1, mid) >= value) {
                    ans = mid;
                    right = mid - 1;
                } else {
                    left = mid + 1;
                }
            }
            update(1, 0, n - 1, ans, -1);
        } else {
            update(1, 0, n - 1, value, 1);
        }
    }

    for(int i = 1; i <= n; i++) {
        if(sum(1, 0, n - 1, 0, i) != 0) {
            cout << i  << endl;
            return 0;
        }
    }
    cout << 0 << endl;

    return 0;
}


#include<iostream>
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define M 1000000007
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
vector <int> a(1000005);
vector <int> st(2*1000105,0);
ll power(ll a,ll n)
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
void build(ll n){//Input mein jo n ki  value that is parameter
        for(int i=0;i<n;i++){
            st[n+i]=a[i];
        }
        for(int i=n-1;i>=0;i--){
            st[i]=st[2*i]+st[2*i+1];
        }
}
void update(ll n,ll pos,ll val){ //pos is the index jispe update hai and val is the value
        st[n+pos]+=val;
        pos+=n;
        while(pos>1){
            st[pos>>1]=st[pos]+st[pos^1];
            pos=pos>>1;
        }
}
ll query(ll n,ll l,ll r){ //l and r are range for query of the form [l,r) matlab r is not included
    l+=n;r+=n;
    ll ans=0;
    while(l<r){
        if(l&1){
            ans+=st[l++];
        }                             //yahan jo bhi operation karna ho karlena
        if(r&1){
            ans+=st[--r];
        }
        l=l>>1;
        r=r>>1;
    }
    return ans;
}
int main(){
    ios;
    ll n,q;
    cin>>n>>q;
    vector <int> input(n);
    inarr(input,n);
    for(int i=0;i<n;i++){
        a[input[i]-1]+=1;
    }
    build(n);
    vector <int> b(q);
    inarr(b,q);
    for(int i=0;i<q;i++){
        if(b[i]>0){
            ll k;
            k=b[i];
            update(n,k-1,1);
        }
        else{
           ll k=abs(b[i]);
            ll l=1,r=n;
            while(l<=r){
                ll mid=(l+r)/2;
                ll ret1=query(n,0,mid);
                if(k<=ret1 && k>=(ret1-st[n+mid-1]+1) && st[n+mid-1]!=0){
                    update(n,mid-1,-1);
                    break;
                }
                else if(k>ret1){
                    l=mid+1;
                }
                else{
                    r=mid-1;
                }
            }
        }
    }
    ll ans=-1;
    for(int i=0;i<n;i++){
        if(st[n+i]>0){
            ans=i+1;
            break;
        }
    }
    if(ans==-1){
        cout<<0<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    return 0;
}


#include<iostream>
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define M 1000000007
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
vector <int> a(1000005);
vector <int> st(2*1000105,0);
ll power(ll a,ll n)
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
void build(ll n){//Input mein jo n ki  value that is parameter
        for(int i=0;i<n;i++){
            st[n+i]=a[i];
        }
        for(int i=n-1;i>=0;i--){
            st[i]=st[2*i]+st[2*i+1];
        }
}
void update(ll n,ll pos,ll val){ //pos is the index jispe update hai and val is the value
        st[n+pos]+=val;
        pos+=n;
        while(pos>1){
            st[pos>>1]=st[pos]+st[pos^1];
            pos=pos>>1;
        }
}
ll query(ll n,ll l,ll r){ //l and r are range for query of the form [l,r) matlab r is not included
    l+=n;r+=n;
    ll ans=0;
    while(l<r){
        if(l&1){
            ans+=st[l++];
        }                             //yahan jo bhi operation karna ho karlena
        if(r&1){
            ans+=st[--r];
        }
        l=l>>1;
        r=r>>1;
    }
    return ans;
}
int main(){
    ios;
    ll n,q;
    cin>>n>>q;
    vector <int> input(n);
    inarr(input,n);
    for(int i=0;i<n;i++){
        a[input[i]-1]+=1;
    }
    build(n);
    vector <int> b(q);
    inarr(b,q);
    for(int i=0;i<q;i++){
        if(b[i]>0){
            ll k;
            k=b[i];
            update(n,k-1,1);
        }
        else{
           ll k=abs(b[i]);
            ll l=1,r=n;
            while(l<=r){
                ll mid=(l+r)/2;
                ll ret1=query(n,0,mid);
                if(ret1==k && st[n+mid-1]!=0){
                    update(n,mid-1,-1);
                    break;
                }
                else if(k>ret1){
                    l=mid+1;
                }
                else{
                    r=mid-1;
                }
            }
        }
    }
    ll ans=-1;
    for(int i=0;i<n;i++){
        if(st[n+i]>0){
            ans=i+1;
            break;
        }
    }
    if(ans==-1){
        cout<<0<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    return 0;
}


#include<iostream>
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define M 1000000007
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
vector <int> a(1000005);
vector <int> st(2*1000105,0);
ll power(ll a,ll n)
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
void build(ll n){//Input mein jo n ki  value that is parameter
        for(int i=0;i<n;i++){
            st[n+i]=a[i];
        }
        for(int i=n-1;i>=0;i--){
            st[i]=st[2*i]+st[2*i+1];
        }
}
void update(ll n,ll pos,ll val){ //pos is the index jispe update hai and val is the value
        st[n+pos]+=val;
        pos+=n;
        while(pos>1){
            st[pos>>1]=st[pos]+st[pos^1];
            pos=pos>>1;
        }
}
ll query(ll n,ll l,ll r){ //l and r are range for query of the form [l,r) matlab r is not included
    l+=n;r+=n;
    ll ans=0;
    while(l<r){
        if(l&1){
            ans+=st[l++];
        }                             //yahan jo bhi operation karna ho karlena
        if(r&1){
            ans+=st[--r];
        }
        l=l>>1;
        r=r>>1;
    }
    return ans;
}
int main(){
    ios;
    ll n,q;
    cin>>n>>q;
    vector <int> input(n);
    inarr(input,n);
    for(int i=0;i<n;i++){
        a[input[i]-1]+=1;
    }
    vector <int> b(q);
    inarr(b,q);
    int pos=q;
    for(int i=0;i<q;i++){
        if(b[i]==-1){
            pos=i;
            break;
        }
        else{
            a[b[i]-1]+=1;
        }
    }
    build(n);
    for(int i=pos;i<q;i++){
        if(b[i]>0){
            ll k;
            k=b[i];
            update(n,k-1,1);
        }
        else{
           ll k=abs(b[i]);
            ll l=1,r=n;
            while(l<=r){
                ll mid=(l+r)/2;
                ll ret1=query(n,0,mid);
                if(k<=ret1 && k>=(ret1-st[n+mid-1]+1) && st[n+mid-1]!=0){
                    update(n,mid-1,-1);
                    break;
                }
                else if(k>ret1){
                    l=mid+1;
                }
                else{
                    r=mid-1;
                }
            }
        }
    }
    ll ans=-1;
    for(int i=0;i<n;i++){
        if(st[n+i]>0){
            ans=i+1;
            break;
        }
    }
    if(ans==-1){
        cout<<0<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    return 0;
}


#include<iostream>
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define M 1000000007
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
vector <int> a(1000005);
vector <int> st(2*1000105,0);
ll power(ll a,ll n)
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
void build(ll n){//Input mein jo n ki  value that is parameter
        for(int i=0;i<n;i++){
            st[n+i]=a[i];
        }
        for(int i=n-1;i>=0;i--){
            st[i]=st[2*i]+st[2*i+1];
        }
}
void update(ll n,ll pos,ll val){ //pos is the index jispe update hai and val is the value
        st[n+pos]+=val;
        pos+=n;
        while(pos>1){
            st[pos>>1]=st[pos]+st[pos^1];
            pos=pos>>1;
        }
}
ll query(ll n,ll l,ll r){ //l and r are range for query of the form [l,r) matlab r is not included
    l+=n;r+=n;
    ll ans=0;
    while(l<r){
        if(l&1){
            ans+=st[l++];
        }                             //yahan jo bhi operation karna ho karlena
        if(r&1){
            ans+=st[--r];
        }
        l=l>>1;
        r=r>>1;
    }
    return ans;
}
int main(){
    ios;
    ll n,q;
    cin>>n>>q;
    vector <int> input(n);
    inarr(input,n);
    for(int i=0;i<n;i++){
        a[input[i]-1]+=1;
    }
    vector <int> b(q);
    inarr(b,q);
    int pos=q;
    for(int i=0;i<q;i++){
        if(b[i]<0){
            pos=i;
            break;
        }
        else{
            a[b[i]-1]+=1;
        }
    }
    build(n);
    for(int i=pos;i<q;i++){
        if(b[i]>0){
            ll k;
            k=b[i];
            update(n,k-1,1);
        }
        else{
           ll k=abs(b[i]);
           ll flag=0;
           if(n>100){
               ll s=0;
               for(int i=0;i<10;i++){
                   s+=st[n+i];
                   if(k<=s){
                       flag=1;
                       update(n,i,-1);
                       break;
                   }
               }
           }
           if(flag==0){
            ll l=1,r=n;
            while(l<=r){
                ll mid=(l+r)/2;
                ll ret1=query(n,0,mid);
                if(k<=ret1 && k>=(ret1-st[n+mid-1]+1) && st[n+mid-1]!=0){
                    update(n,mid-1,-1);
                    break;
                }
                else if(k>ret1){
                    l=mid+1;
                }
                else{
                    r=mid-1;
                }
            }
        }}
    }
    ll ans=-1;
    for(int i=0;i<n;i++){
        if(st[n+i]>0){
            ans=i+1;
            break;
        }
    }
    if(ans==-1){
        cout<<0<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    return 0;
}


#include<iostream>
#include<vector>
#define ll long long int
#define pb push_back
#define endl "\n"
#define M 1000000007
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
vector <int> bt(1000005,0);
vector <int> a(1000005,0);
void update(int n,int pos,int val){ // pos isme jo value pass hora wo 0 based hai
    pos+=1;                         // par yahan pe BT is 1 based isliye +1
    while(pos<=n){
        bt[pos]+=val;          //Baaki idhar kuch karna hai toh kar sakte operation
        pos+=(pos&(-pos));
    }
}
ll query(int pos){           //isme bhi same pos is 0 based but andar +1 kardete
    ll sum=0;
    pos+=1;
    while(pos>0){
        sum+=bt[pos];
        pos-=(pos&(-pos));
    }
    return sum;
}
void build(int n){
    for(int i=0;i<n;i++){
        update(n,i,a[i]);
    }
}
int main(){
    ios;
    ll n,q;
    cin>>n>>q;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        a[x-1]+=1;
    }
    vector <int> b(q);
    inarr(b,q);
    build(n);
    for(int i=0;i<q;i++){
        if(b[i]>0){
            ll k;
            k=b[i];
            update(n,k-1,1);
            a[k-1]+=1;
        }
        else{
           ll k=abs(b[i]);
           ll flag=0;
           if(flag==0){
            ll l=0,r=n-1;
            while(l<=r){
                ll mid=(l+r)/2;
                ll ret1=query(mid);
                if(k<=ret1 && k>=(ret1-a[mid]+1) && a[mid]!=0){
                    update(n,mid,-1);
                    a[mid]-=1;
                    break;
                }
                else if(k>ret1){
                    l=mid+1;
                }
                else{
                    r=mid-1;
                }
            }
        }}
    }
    ll ans=-1;
    for(int i=0;i<n;i++){
        if(a[i]>0){
            ans=i+1;
            break;
        }
    }
    if(ans==-1){
        cout<<0<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    return 0;
}


#include<iostream>
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define M 1000000007
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
vector <int> a(1000005);
vector <int> st(2*1000105,0);
ll power(ll a,ll n)
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
void build(ll n){//Input mein jo n ki  value that is parameter
        for(int i=0;i<n;i++){
            st[n+i]=a[i];
        }
        for(int i=n-1;i>=0;i--){
            st[i]=st[2*i]+st[2*i+1];
        }
}
void update(ll n,ll pos,ll val){ //pos is the index jispe update hai and val is the value
        st[n+pos]+=val;
        pos+=n;
        while(pos>1){
            st[pos>>1]=st[pos]+st[pos^1];
            pos=pos>>1;
        }
}
ll query(ll n,ll l,ll r){ //l and r are range for query of the form [l,r) matlab r is not included
    l+=n;r+=n;
    ll ans=0;
    while(l<r){
        if(l&1){
            ans+=st[l++];
        }                             //yahan jo bhi operation karna ho karlena
        if(r&1){
            ans+=st[--r];
        }
        l=l>>1;
        r=r>>1;
    }
    return ans;
}
int main(){
    ios;
    ll n,q;
    cin>>n>>q;
    vector <int> input(n);
    inarr(input,n);
    for(int i=0;i<n;i++){
        a[input[i]-1]+=1;
    }
    vector <int> b(q);
    inarr(b,q);
    int pos=q;
    for(int i=0;i<q;i++){
        if(b[i]<0){
            pos=i;
            break;
        }
        else{
            a[b[i]-1]+=1;
        }
    }
    build(n);
    for(int i=pos;i<q;i++){
        if(b[i]>0){
            ll k;
            k=b[i];
            update(n,k-1,1);
        }
        else{
           ll k=abs(b[i]);
            ll l=1,r=n;
            while(l<=r){
                ll mid=(l+r)/2;
                ll ret1=query(n,0,mid);
                if(k<=ret1 && k>=(ret1-st[n+mid-1]+1) && st[n+mid-1]!=0){
                    update(n,mid-1,-1);
                    break;
                }
                else if(k>ret1){
                    l=mid+1;
                }
                else{
                    r=mid-1;
                }
            }
        }
    }
    ll ans=-1;
    for(int i=0;i<n;i++){
        if(st[n+i]>0){
            ans=i+1;
            break;
        }
    }
    if(ans==-1){
        cout<<0<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    return 0;
}


#include<iostream>
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define M 1000000007
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
vector <ll> a(1000005);
vector <ll> st(2*1000105,0);
ll power(ll a,ll n)
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
void build(ll n){//Input mein jo n ki  value that is parameter
        for(int i=0;i<n;i++){
            st[n+i]=a[i];
        }
        for(int i=n-1;i>=0;i--){
            st[i]=st[2*i]+st[2*i+1];
        }
}
void update(ll n,ll pos,ll val){ //pos is the index jispe update hai and val is the value
        st[n+pos]+=val;
        pos+=n;
        while(pos>1){
            st[pos>>1]=st[pos]+st[pos^1];
            pos=pos>>1;
        }
}
ll query(ll n,ll l,ll r){ //l and r are range for query of the form [l,r) matlab r is not included
    l+=n;r+=n;
    ll ans=0;
    while(l<r){
        if(l&1){
            ans+=st[l++];
        }                             //yahan jo bhi operation karna ho karlena
        if(r&1){
            ans+=st[--r];
        }
        l=l>>1;
        r=r>>1;
    }
    return ans;
}
int main(){
    ll n,q;
    cin>>n>>q;
    vector <ll> input(n);
    inarr(input,n);
    for(int i=0;i<n;i++){
        a[input[i]-1]+=1;
    }
    build(n);
    vector <ll> b(q);
    inarr(b,q);
    for(int i=0;i<q;i++){
        if(b[i]>0){
            ll k;
            k=b[i];
            update(n,k-1,1);
        }
        else{
           ll k=abs(b[i]);
            ll l=1,r=n;
            while(l<=r){
                ll mid=(l+r)/2;
                ll ret1=query(n,0,mid);
                if(ret1==k && st[n+mid-1]!=0){
                    update(n,mid-1,-1);
                    break;
                }
                else if(k>ret1){
                    l=mid+1;
                }
                else{
                    r=mid-1;
                }
            }
        }
    }
    ll ans=-1;
    for(int i=0;i<n;i++){
        if(st[n+i]>0){
            ans=i+1;
            break;
        }
    }
    if(ans==-1){
        cout<<0<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    return 0;
}


#include<iostream>
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define M 1000000007
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
vector <int> a(1000005);
vector <int> st(2*1000105,0);
ll power(ll a,ll n)
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
void build(ll n){//Input mein jo n ki  value that is parameter
        for(int i=0;i<n;i++){
            st[n+i]=a[i];
        }
        for(int i=n-1;i>=0;i--){
            st[i]=st[2*i]+st[2*i+1];
        }
}
void update(ll n,ll pos,ll val){ //pos is the index jispe update hai and val is the value
        st[n+pos]+=val;
        pos+=n;
        while(pos>1){
            st[pos>>1]=st[pos]+st[pos^1];
            pos=pos>>1;
        }
}
ll query(ll n,ll l,ll r){ //l and r are range for query of the form [l,r) matlab r is not included
    l+=n;r+=n;
    ll ans=0;
    while(l<r){
        if(l&1){
            ans+=st[l++];
        }                             //yahan jo bhi operation karna ho karlena
        if(r&1){
            ans+=st[--r];
        }
        l=l>>1;
        r=r>>1;
    }
    return ans;
}
int main(){
    ll n,q;
    cin>>n>>q;
    vector <int> input(n);
    inarr(input,n);
    for(int i=0;i<n;i++){
        a[input[i]-1]+=1;
    }
    build(n);
    vector <int> b(q);
    inarr(b,q);
    for(int i=0;i<q;i++){
        if(b[i]>0){
            ll k;
            k=b[i];
            update(n,k-1,1);
        }
        else{
           ll k=abs(b[i]);
            ll l=1,r=n;
            while(l<=r){
                ll mid=(l+r)/2;
                ll ret1=query(n,0,mid);
                if(ret1==k && st[n+mid-1]!=0){
                    update(n,mid-1,-1);
                    break;
                }
                else if(k>ret1){
                    l=mid+1;
                }
                else{
                    r=mid-1;
                }
            }
        }
    }
    ll ans=-1;
    for(int i=0;i<n;i++){
        if(st[n+i]>0){
            ans=i+1;
            break;
        }
    }
    if(ans==-1){
        cout<<0<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    return 0;
}


#include<iostream>
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define M 1000000007
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
vector <int> a(1000005);
vector <int> st(2*1000105,0);
ll power(ll a,ll n)
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
void build(ll n){//Input mein jo n ki  value that is parameter
        for(int i=0;i<n;i++){
            st[n+i]=a[i];
        }
        for(int i=n-1;i>=0;i--){
            st[i]=st[2*i]+st[2*i+1];
        }
}
void update(ll n,ll pos,ll val){ //pos is the index jispe update hai and val is the value
        st[n+pos]+=val;
        pos+=n;
        while(pos>1){
            st[pos>>1]=st[pos]+st[pos^1];
            pos=pos>>1;
        }
}
ll query(ll n,ll l,ll r){ //l and r are range for query of the form [l,r) matlab r is not included
    l+=n;r+=n;
    ll ans=0;
    while(l<r){
        if(l&1){
            ans+=st[l++];
        }                             //yahan jo bhi operation karna ho karlena
        if(r&1){
            ans+=st[--r];
        }
        l=l>>1;
        r=r>>1;
    }
    return ans;
}
int main(){
    ios;
    ll n,q;
    cin>>n>>q;
    vector <int> input(n);
    inarr(input,n);
    for(int i=0;i<n;i++){
        a[input[i]-1]+=1;
    }
    vector <int> b(q);
    inarr(b,q);
    int pos=-1;
    for(int i=0;i<q;i++){
        if(b[i]==-1){
            pos=i;
            break;
        }
        else{
            a[b[i]-1]+=1;
        }
    }
    build(n);
    for(int i=pos;i<q;i++){
        if(b[i]>0){
            ll k;
            k=b[i];
            update(n,k-1,1);
        }
        else{
           ll k=abs(b[i]);
            ll l=1,r=n;
            while(l<=r){
                ll mid=(l+r)/2;
                ll ret1=query(n,0,mid);
                if(k<=ret1 && k>=(ret1-st[n+mid-1]+1) && st[n+mid-1]!=0){
                    update(n,mid-1,-1);
                    break;
                }
                else if(k>ret1){
                    l=mid+1;
                }
                else{
                    r=mid-1;
                }
            }
        }
    }
    ll ans=-1;
    for(int i=0;i<n;i++){
        if(st[n+i]>0){
            ans=i+1;
            break;
        }
    }
    if(ans==-1){
        cout<<0<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    return 0;
}


#include<iostream>
#include<vector>
#define ll long long int
#define pb push_back
#define endl "\n"
#define M 1000000007
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
vector <int> a(1000005);
vector <int> st(2*1000105,0);
ll power(ll a,ll n)
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
void build(ll n){//Input mein jo n ki  value that is parameter
        for(int i=0;i<n;i++){
            st[n+i]=a[i];
        }
        for(int i=n-1;i>=0;i--){
            st[i]=st[2*i]+st[2*i+1];
        }
}
void update(ll n,ll pos,ll val){ //pos is the index jispe update hai and val is the value
        st[n+pos]+=val;
        pos+=n;
        while(pos>1){
            st[pos>>1]=st[pos]+st[pos^1];
            pos=pos>>1;
        }
}
ll query(ll n,ll l,ll r){ //l and r are range for query of the form [l,r) matlab r is not included
    l+=n;r+=n;
    ll ans=0;
    while(l<r){
        if(l&1){
            ans+=st[l++];
        }                             //yahan jo bhi operation karna ho karlena
        if(r&1){
            ans+=st[--r];
        }
        l=l>>1;
        r=r>>1;
    }
    return ans;
}
int main(){
    ios;
    ll n,q;
    cin>>n>>q;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        a[x-1]+=1;
    }
    vector <int> b(q);
    inarr(b,q);
    int pos=q;
    for(int i=0;i<q;i++){
        if(b[i]<0){
            pos=i;
            break;
        }
        else{
            a[b[i]-1]+=1;
        }
    }
    build(n);
    for(int i=pos;i<q;i++){
        if(b[i]>0){
            ll k;
            k=b[i];
            update(n,k-1,1);
        }
        else{
           ll k=abs(b[i]);
           ll flag=0;
           if(n>100){
               ll s=0;
               for(int i=0;i<10;i++){
                   s+=st[n+i];
                   if(k<=s){
                       flag=1;
                       update(n,i,-1);
                       break;
                   }
               }
           }
           if(flag==0){
            ll l=1,r=n;
            while(l<=r){
                ll mid=(l+r)/2;
                ll ret1=query(n,0,mid);
                if(k<=ret1 && k>=(ret1-st[n+mid-1]+1) && st[n+mid-1]!=0){
                    update(n,mid-1,-1);
                    break;
                }
                else if(k>ret1){
                    l=mid+1;
                }
                else{
                    r=mid-1;
                }
            }
        }}
    }
    ll ans=-1;
    for(int i=0;i<n;i++){
        if(st[n+i]>0){
            ans=i+1;
            break;
        }
    }
    if(ans==-1){
        cout<<0<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    return 0;
}


#include<iostream>
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define M 1000000007
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
vector <int> a(1000005);
vector <int> st(2*1000105,0);
ll power(ll a,ll n)
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
void build(ll n){//Input mein jo n ki  value that is parameter
        for(int i=0;i<n;i++){
            st[n+i]=a[i];
        }
        for(int i=n-1;i>=0;i--){
            st[i]=st[2*i]+st[2*i+1];
        }
}
void update(ll n,ll pos,ll val){ //pos is the index jispe update hai and val is the value
        st[n+pos]+=val;
        pos+=n;
        while(pos>1){
            st[pos>>1]=st[pos]+st[pos^1];
            pos=pos>>1;
        }
}
ll query(ll n,ll l,ll r){ //l and r are range for query of the form [l,r) matlab r is not included
    l+=n;r+=n;
    ll ans=0;
    while(l<r){
        if(l&1){
            ans+=st[l++];
        }                             //yahan jo bhi operation karna ho karlena
        if(r&1){
            ans+=st[--r];
        }
        l=l>>1;
        r=r>>1;
    }
    return ans;
}
int main(){
    ios;
    ll n,q;
    cin>>n>>q;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        a[x-1]+=1;
    }
    vector <int> b(q);
    inarr(b,q);
    int pos=q;
    for(int i=0;i<q;i++){
        if(b[i]<0){
            pos=i;
            break;
        }
        else{
            a[b[i]-1]+=1;
        }
    }
    build(n);
    for(int i=pos;i<q;i++){
        if(b[i]>0){
            ll k;
            k=b[i];
            update(n,k-1,1);
        }
        else{
           ll k=abs(b[i]);
           ll flag=0;
           if(n>100){
               ll s=0;
               for(int i=0;i<10;i++){
                   s+=st[n+i];
                   if(k<=s){
                       flag=1;
                       update(n,i,-1);
                       break;
                   }
               }
           }
           if(flag==0){
            ll l=1,r=n;
            while(l<=r){
                ll mid=(l+r)/2;
                ll ret1=query(n,0,mid);
                if(k<=ret1 && k>=(ret1-st[n+mid-1]+1) && st[n+mid-1]!=0){
                    update(n,mid-1,-1);
                    break;
                }
                else if(k>ret1){
                    l=mid+1;
                }
                else{
                    r=mid-1;
                }
            }
        }}
    }
    ll ans=-1;
    for(int i=0;i<n;i++){
        if(st[n+i]>0){
            ans=i+1;
            break;
        }
    }
    if(ans==-1){
        cout<<0<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    return 0;
}


#include<iostream>
#include<vector>
#define ll long long int
#define pb push_back
#define endl "\n"
#define M 1000000007
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
vector <int> bt(1000005,0);
vector <int> a(1000005,0);
void update(int n,int pos,int val){ // pos isme jo value pass hora wo 0 based hai
    pos+=1;                         // par yahan pe BT is 1 based isliye +1
    while(pos<=n){
        bt[pos]+=val;          //Baaki idhar kuch karna hai toh kar sakte operation
        pos+=(pos&(-pos));
    }
}
ll query(int pos){           //isme bhi same pos is 0 based but andar +1 kardete
    ll sum=0;
    pos+=1;
    while(pos>0){
        sum+=bt[pos];
        pos-=(pos&(-pos));
    }
    return sum;
}
void build(int n){
    for(int i=0;i<n;i++){
        update(n,i,a[i]);
    }
}
int main(){
    ios;
    ll n,q;
    cin>>n>>q;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        a[x-1]+=1;
    }
    vector <int> b(q);
    inarr(b,q);
    ll positive=0;
    ll neg=0;
    for(int i=0;i<q;i++){
        if(b[i]<0){
            neg++;
        }
        else{
            positive++;
        }
    }
    positive+=n;
    if(positive==neg){
        cout<<0<<endl;
        return 0;
    }
    int pos=q;
    for(int i=0;i<q;i++){
        if(b[i]<0){
            pos=i;
            break;
        }
        else{
            a[b[i]-1]+=1;
        }
    }
    build(n);
    for(int i=pos;i<q;i++){
        if(b[i]>0){
            ll k;
            k=b[i];
            update(n,k-1,1);
            a[k-1]+=1;
        }
        else{
           ll k=abs(b[i]);
           ll flag=0;
           if(flag==0){
            ll l=0,r=n-1;
            while(l<=r){
                ll mid=(l+r)/2;
                ll ret1=query(mid);
                if(k<=ret1 && k>=(ret1-a[mid]+1) && a[mid]!=0){
                    update(n,mid,-1);
                    a[mid]-=1;
                    break;
                }
                else if(k>ret1){
                    l=mid+1;
                }
                else{
                    r=mid-1;
                }
            }
        }}
    }
    ll ans=-1;
    for(int i=0;i<n;i++){
        if(a[i]>0){
            ans=i+1;
            break;
        }
    }
    if(ans==-1){
        cout<<0<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    return 0;
}


#include "bits/stdc++.h"
#if !defined(ONLINE_JUDGE)
#include "prettyprint/prettyprint.hpp"
#endif
using namespace std;
typedef long long ll;

#define all(x) x.begin(), x.end()
#define pi 3.14159265358979323846

template<class Container> istream& operator>> (istream &in, vector<Container> &c) {for(auto &x :c) in >> x; return in; }
template<class A, class B> istream& operator>> (istream &in, pair<A, B> &c) {in >> c.first >> c.second; return in; }
template<class Container> ll gcd(Container &a) { auto g = *a.begin(); for(auto &x : a) g = __gcd(g, x); return g; }
template<typename T> T Min(const T &a){ return a; }
template<typename T, typename ...Args> T Min(const T &a, const Args&... args) { T b = Min(args...); return (a < b ? a : b);}
template<typename T> T Max(const T &a) { return a; }
template<typename T, typename ...Args> T Max(const T &a, const Args&... args) { T b = Max(args...); return (a > b ? a : b); }
template<typename T> T gcd(const T &a){ return a; }

const int N = (int)1e6+2;
int tree[4*N];
void add(int v, int tl, int tr, int pos, int val)
{
    tree[v]+=val;
    if(tl == tr)
        return;
    int tm = (tl + tr) >> 1;
    (pos <= tm ? add((v << 1), tl, tm, pos, val) : add((v << 1 | 1), tm + 1, tr, pos, val));
}
int kth(int v, int tl, int tr, int k)
{
    if(tl == tr) return tl;
    int tm = (tl + tr) >> 1;
    if(tree[v << 1] >= k) return kth(v << 1, tl, tm, k);
    else return kth(v << 1 | 1, tm + 1, tr, k - tree[v << 1]);
}
int findAnswer(int v, int tl, int tr)
{
    if(tl == tr)
        return tl;
    int tm = (tl + tr) >> 1;
    if(tree[v << 1]) return findAnswer(v << 1, tl, tm);
    else if(tree[v << 1 | 1]) return findAnswer(v << 1 | 1, tm + 1, tr);
    else return 0;
}
int main()
{
    int n, q; cin >> n >> q;
    int x;
    for(int i = 0; i < n; i++) {
        scanf("%d", &x);
        add(1, 1, N - 1, x, 1);
    }
    for(int i = 0; i < q; i++) {
        scanf("%d", &x);
        int v = kth(1, 1, N - 1, abs(x));
        add(1, 1, N - 1, v, (x < 0 ? -1 : 1));
    }
    printf("%d", findAnswer(1, 1, N - 1));
}


#include "bits/stdc++.h"
#if !defined(ONLINE_JUDGE)
#include "prettyprint/prettyprint.hpp"
#endif
using namespace std;
typedef long long ll;

#define all(x) x.begin(), x.end()
#define pi 3.14159265358979323846

template<class Container> istream& operator>> (istream &in, vector<Container> &c) {for(auto &x :c) in >> x; return in; }
template<class A, class B> istream& operator>> (istream &in, pair<A, B> &c) {in >> c.first >> c.second; return in; }
template<class Container> ll gcd(Container &a) { auto g = *a.begin(); for(auto &x : a) g = __gcd(g, x); return g; }
template<typename T> T Min(const T &a){ return a; }
template<typename T, typename ...Args> T Min(const T &a, const Args&... args) { T b = Min(args...); return (a < b ? a : b);}
template<typename T> T Max(const T &a) { return a; }
template<typename T, typename ...Args> T Max(const T &a, const Args&... args) { T b = Max(args...); return (a > b ? a : b); }
template<typename T> T gcd(const T &a){ return a; }

const int N = (int)1e6+2;
int tree[4*N];
void add(int v, int tl, int tr, int pos, int val)
{
    if(tl == pos && tl == tr) tree[v] += val;
    else {
        int tm = (tl + tr) >> 1;
        (pos <= tm ? add((v << 1), tl, tm, pos, val) : add((v << 1 | 1), tm + 1, tr, pos, val));
        tree[v] = tree[v << 1] + tree[v << 1 | 1];
    }
}
int kth(int v, int tl, int tr, int k)
{
    if(tl == tr) return tl;
    int tm = (tl + tr) >> 1;
    if(tree[v << 1] >= k) return kth(v << 1, tl, tm, k);
    else return kth(v << 1 | 1, tm + 1, tr, k - tree[v << 1]);
}
int findAnswer(int v, int tl, int tr)
{
    if(tl == tr)
        return tl;
    int tm = (tl + tr) >> 1;
    if(tree[v << 1]) return findAnswer(v << 1, tl, tm);
    else if(tree[v << 1 | 1]) return findAnswer(v << 1 | 1, tm + 1, tr);
    else return 0;
}
int main()
{
    int n, q; cin >> n >> q;
    int x;
    for(int i = 0; i < n; i++) {
        scanf("%d", &x);
        add(1, 0, N - 1, x, 1);
    }
    for(int i = 0; i < q; i++) {
        scanf("%d", &x);
        int v = kth(1, 0, N - 1, abs(x));
        add(1, 0, N - 1, v, -1);
    }
    printf("%d", findAnswer(1, 0, N - 1));
}


#include "bits/stdc++.h"
#if !defined(ONLINE_JUDGE)
#include "prettyprint/prettyprint.hpp"
#endif
using namespace std;
typedef long long ll;

#define all(x) x.begin(), x.end()
#define pi 3.14159265358979323846

template<class Container> istream& operator>> (istream &in, vector<Container> &c) {for(auto &x :c) in >> x; return in; }
template<class A, class B> istream& operator>> (istream &in, pair<A, B> &c) {in >> c.first >> c.second; return in; }
template<class Container> ll gcd(Container &a) { auto g = *a.begin(); for(auto &x : a) g = __gcd(g, x); return g; }
template<typename T> T Min(const T &a){ return a; }
template<typename T, typename ...Args> T Min(const T &a, const Args&... args) { T b = Min(args...); return (a < b ? a : b);}
template<typename T> T Max(const T &a) { return a; }
template<typename T, typename ...Args> T Max(const T &a, const Args&... args) { T b = Max(args...); return (a > b ? a : b); }
template<typename T> T gcd(const T &a){ return a; }

const int N = (int)1e6+2;
int tree[4*N];
void add(int v, int tl, int tr, int pos, int val)
{
    tree[v]+=val;
    if(tl == tr)
        return;
    int tm = (tl + tr) >> 1;
    (pos <= tm ? add((v << 1), tl, tm, pos, val) : add((v << 1 | 1), tm + 1, tr, pos, val));
}
int kth(int v, int tl, int tr, int k)
{
    if(tl == tr) return tl;
    int tm = (tl + tr) >> 1;
    if(tree[v << 1] >= k) return kth(v << 1, tl, tm, k);
    else return kth(v << 1 | 1, tm + 1, tr, k - tree[v << 1]);
}
int findAnswer(int v, int tl, int tr)
{
    if(tl == tr)
        return tl;
    int tm = (tl + tr) >> 1;
    if(tree[v << 1]) return findAnswer(v << 1, tl, tm);
    else if(tree[v << 1 | 1]) return findAnswer(v << 1 | 1, tm + 1, tr);
    else return 0;
}
int main()
{
    int n, q; cin >> n >> q;
    int x;
    for(int i = 0; i < n; i++) {
        scanf("%d", &x);
        add(1, 1, N - 1, x, 1);
    }
    for(int i = 0; i < q; i++) {
        scanf("%d", &x);
        if(x < 0) {
            int v = kth(1, 1, N - 1, abs(x));
            add(1, 1, N - 1, v, -1);
        } else  add(1, 1, N - 1, x, 1);
    }
    printf("%d", findAnswer(1, 1, N - 1));
}


#include "bits/stdc++.h"
#if !defined(ONLINE_JUDGE)
#include "prettyprint/prettyprint.hpp"
#endif
using namespace std;
typedef long long ll;

#define all(x) x.begin(), x.end()
#define pi 3.14159265358979323846

template<class Container> istream& operator>> (istream &in, vector<Container> &c) {for(auto &x :c) in >> x; return in; }
template<class A, class B> istream& operator>> (istream &in, pair<A, B> &c) {in >> c.first >> c.second; return in; }
template<class Container> ll gcd(Container &a) { auto g = *a.begin(); for(auto &x : a) g = __gcd(g, x); return g; }
template<typename T> T Min(const T &a){ return a; }
template<typename T, typename ...Args> T Min(const T &a, const Args&... args) { T b = Min(args...); return (a < b ? a : b);}
template<typename T> T Max(const T &a) { return a; }
template<typename T, typename ...Args> T Max(const T &a, const Args&... args) { T b = Max(args...); return (a > b ? a : b); }
template<typename T> T gcd(const T &a){ return a; }

const int N = 6;
int tree[4*N];
void add(int v, int tl, int tr, int pos, int val)
{
    if(tl == pos && tl == tr) tree[v] += val;
    else {
        int tm = (tl + tr) >> 1;
        (pos <= tm ? add((v << 1), tl, tm, pos, val) : add((v << 1 | 1), tm + 1, tr, pos, val));
        tree[v] = tree[v << 1] + tree[v << 1 | 1];
    }
}
int kth(int v, int tl, int tr, int k)
{
    if(tl == tr) return tl;
    int tm = (tl + tr) >> 1;
    if(tree[v << 1] >= k) return kth(v << 1, tl, tm, k);
    else return kth(v << 1 | 1, tm + 1, tr, k - tree[v << 1]);
}
int findAnswer(int v, int tl, int tr)
{
    if(tl == tr) return tl;
    int tm = (tl + tr) >> 1;
    if(tree[v << 1]) return findAnswer(v << 1, tl, tm);
    else if(tree[v << 1 | 1]) return findAnswer(v << 1 | 1, tm + 1, tr);
    else return 0;
}
int main()
{
    int n, q; cin >> n >> q;
    int a[n], t[q];
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);
    for(int i = 0; i < q; i++) scanf("%d", &t[i]);
    for(auto &x : a)
        add(1, 0, N - 1, x, 1);
    for(auto &x : t) {
        int v = kth(1, 0, N - 1, abs(x));
        add(1, 0, N - 1, v, -1);
    }
    printf("%d", findAnswer(1, 0, N - 1));
}


#include "bits/stdc++.h"
#if !defined(ONLINE_JUDGE)
#include "prettyprint/prettyprint.hpp"
#endif
using namespace std;
typedef long long ll;

#define all(x) x.begin(), x.end()
#define pi 3.14159265358979323846

template<class Container> istream& operator>> (istream &in, vector<Container> &c) {for(auto &x :c) in >> x; return in; }
template<class A, class B> istream& operator>> (istream &in, pair<A, B> &c) {in >> c.first >> c.second; return in; }
template<class Container> ll gcd(Container &a) { auto g = *a.begin(); for(auto &x : a) g = __gcd(g, x); return g; }
template<typename T> T Min(const T &a){ return a; }
template<typename T, typename ...Args> T Min(const T &a, const Args&... args) { T b = Min(args...); return (a < b ? a : b);}
template<typename T> T Max(const T &a) { return a; }
template<typename T, typename ...Args> T Max(const T &a, const Args&... args) { T b = Max(args...); return (a > b ? a : b); }
template<typename T> T gcd(const T &a){ return a; }

const int N = 6;
int tree[4*N];
void add(int v, int tl, int tr, int pos, int val)
{
    if(tl == pos && tl == tr) tree[v] += val;
    else {
        int tm = (tl + tr) >> 1;
        (pos <= tm ? add((v << 1), tl, tm, pos, val) : add((v << 1 | 1), tm + 1, tr, pos, val));
        tree[v] = tree[v << 1] + tree[v << 1 | 1];
    }
}
int kth(int v, int tl, int tr, int k)
{
    if(tl == tr) return tl;
    int tm = (tl + tr) >> 1;
    if(tree[v << 1] >= k) return kth(v << 1, tl, tm, k);
    else return kth(v << 1 | 1, tm + 1, tr, k - tree[v << 1]);
}
int findAnswer(int v, int tl, int tr)
{
    if(tl == tr) return tl;
    int tm = (tl + tr) >> 1;
    if(tree[v << 1]) return findAnswer(v << 1, tl, tm);
    else if(tree[v << 1 | 1]) return findAnswer(v << 1 | 1, tm + 1, tr);
    else return 0;
}
int main()
{
    int n, q; cin >> n >> q;
    int a[n], t[q];
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < q; i++) cin >> t[i];
    for(auto &x : a)
        add(1, 0, N - 1, x, 1);
    for(auto &x : t) {
        int v = kth(1, 0, N - 1, abs(x));
        add(1, 0, N - 1, v, -1);
    }
    cout << findAnswer(1, 0, N - 1);
}


#include "bits/stdc++.h"
#if !defined(ONLINE_JUDGE)
#include "prettyprint/prettyprint.hpp"
#endif
using namespace std;
typedef long long ll;

#define all(x) x.begin(), x.end()
#define pi 3.14159265358979323846

template<class Container> istream& operator>> (istream &in, vector<Container> &c) {for(auto &x :c) in >> x; return in; }
template<class A, class B> istream& operator>> (istream &in, pair<A, B> &c) {in >> c.first >> c.second; return in; }
template<class Container> ll gcd(Container &a) { auto g = *a.begin(); for(auto &x : a) g = __gcd(g, x); return g; }
template<typename T> T Min(const T &a){ return a; }
template<typename T, typename ...Args> T Min(const T &a, const Args&... args) { T b = Min(args...); return (a < b ? a : b);}
template<typename T> T Max(const T &a) { return a; }
template<typename T, typename ...Args> T Max(const T &a, const Args&... args) { T b = Max(args...); return (a > b ? a : b); }
template<typename T> T gcd(const T &a){ return a; }

const int N = (int)1e6+2;
int tree[4*N];
void add(int v, int tl, int tr, int pos, int val)
{
    if(tl == pos && tl == tr) tree[v] += val;
    else {
        int tm = (tl + tr) >> 1;
        (pos <= tm ? add((v << 1), tl, tm, pos, val) : add((v << 1 | 1), tm + 1, tr, pos, val));
        tree[v]+=val;
    }
}
int kth(int v, int tl, int tr, int k)
{
    if(tl == tr) return tl;
    int tm = (tl + tr) >> 1;
    if(tree[v << 1] >= k) return kth(v << 1, tl, tm, k);
    else return kth(v << 1 | 1, tm + 1, tr, k - tree[v << 1]);
}
int findAnswer(int v, int tl, int tr)
{
    if(tl == tr)
        return tl;
    int tm = (tl + tr) >> 1;
    if(tree[v << 1]) return findAnswer(v << 1, tl, tm);
    else if(tree[v << 1 | 1]) return findAnswer(v << 1 | 1, tm + 1, tr);
    else return 0;
}
int main()
{
    int n, q; cin >> n >> q;
    int x;
    for(int i = 0; i < n; i++) {
        scanf("%d", &x);
        add(1, 0, N - 1, x, 1);
    }
    for(int i = 0; i < q; i++) {
        scanf("%d", &x);
        int v = kth(1, 0, N - 1, abs(x));
        add(1, 0, N - 1, v, -1);
    }
    printf("%d", findAnswer(1, 0, N - 1));
}


#include "bits/stdc++.h"
#if !defined(ONLINE_JUDGE)
#include "prettyprint/prettyprint.hpp"
#endif
using namespace std;
typedef long long ll;

#define all(x) x.begin(), x.end()
#define pi 3.14159265358979323846

template<class Container> istream& operator>> (istream &in, vector<Container> &c) {for(auto &x :c) in >> x; return in; }
template<class A, class B> istream& operator>> (istream &in, pair<A, B> &c) {in >> c.first >> c.second; return in; }
template<class Container> ll gcd(Container &a) { auto g = *a.begin(); for(auto &x : a) g = __gcd(g, x); return g; }
template<typename T> T Min(const T &a){ return a; }
template<typename T, typename ...Args> T Min(const T &a, const Args&... args) { T b = Min(args...); return (a < b ? a : b);}
template<typename T> T Max(const T &a) { return a; }
template<typename T, typename ...Args> T Max(const T &a, const Args&... args) { T b = Max(args...); return (a > b ? a : b); }
template<typename T> T gcd(const T &a){ return a; }

const int N = (int)1e6+2;
int tree[4*N];
void add(int v, int tl, int tr, int pos, int val)
{
    if(tl == pos && tl == tr) tree[v] += val;
    else {
        int tm = (tl + tr) >> 1;
        (pos <= tm ? add((v << 1), tl, tm, pos, val) : add((v << 1 | 1), tm + 1, tr, pos, val));
        tree[v] = tree[v << 1] + tree[v << 1 | 1];
    }
}
int kth(int v, int tl, int tr, int k)
{
    if(tl == tr) return tl;
    int tm = (tl + tr) >> 1;
    if(tree[v << 1] >= k) return kth(v << 1, tl, tm, k);
    else return kth(v << 1 | 1, tm + 1, tr, k - tree[v << 1]);
}
int findAnswer(int v, int tl, int tr)
{
    if(!tree[v])
        return 0;
    if(tl == tr)
        return tl;
    int tm = (tl + tr) >> 1;
    if(tree[v << 1]) return findAnswer(v << 1, tl, tm);
    else if(tree[v << 1 | 1]) return findAnswer(v << 1 | 1, tm + 1, tr);
    else return 0;
}
int main()
{
    int n, q; cin >> n >> q;
    int x;
    for(int i = 0; i < n; i++) {
        scanf("%d", &x);
        add(1, 0, N - 1, x, 1);
    }
    for(int i = 0; i < q; i++) {
        scanf("%d", &x);
        int v = kth(1, 0, N - 1, abs(x));
        add(1, 0, N - 1, v, -1);
    }
    printf("%d", findAnswer(1, 0, N - 1));
}


#include "bits/stdc++.h"
#if !defined(ONLINE_JUDGE)
#include "prettyprint/prettyprint.hpp"
#endif
using namespace std;
typedef long long ll;

#define all(x) x.begin(), x.end()
#define pi 3.14159265358979323846

template<class Container> istream& operator>> (istream &in, vector<Container> &c) {for(auto &x :c) in >> x; return in; }
template<class A, class B> istream& operator>> (istream &in, pair<A, B> &c) {in >> c.first >> c.second; return in; }
template<class Container> ll gcd(Container &a) { auto g = *a.begin(); for(auto &x : a) g = __gcd(g, x); return g; }
template<typename T> T Min(const T &a){ return a; }
template<typename T, typename ...Args> T Min(const T &a, const Args&... args) { T b = Min(args...); return (a < b ? a : b);}
template<typename T> T Max(const T &a) { return a; }
template<typename T, typename ...Args> T Max(const T &a, const Args&... args) { T b = Max(args...); return (a > b ? a : b); }
template<typename T> T gcd(const T &a){ return a; }

const int N = (int)1e6+2;
int tree[4*N];
void add(int v, int tl, int tr, int pos, int val)
{
    tree[v]+=val;
    if(tl == tr)
        return;
    int tm = (tl + tr) >> 1;
    (pos <= tm ? add((v << 1), tl, tm, pos, val) : add((v << 1 | 1), tm + 1, tr, pos, val));
}
int kth(int v, int tl, int tr, int k)
{
    if(tl == tr) return tl;
    int tm = (tl + tr) >> 1;
    if(tree[v << 1] >= k) return kth(v << 1, tl, tm, k);
    else return kth(v << 1 | 1, tm + 1, tr, k - tree[v << 1]);
}
int findAnswer(int v, int tl, int tr)
{
    if(tl == tr)
        return tl;
    int tm = (tl + tr) >> 1;
    if(tree[v << 1]) return findAnswer(v << 1, tl, tm);
    else if(tree[v << 1 | 1]) return findAnswer(v << 1 | 1, tm + 1, tr);
    else return 0;
}
int main()
{
    int n, q; cin >> n >> q;
    int x;
    for(int i = 0; i < n; i++) {
        scanf("%d", &x);
        add(1, 1, N - 1, x, 1);
    }
    for(int i = 0; i < q; i++) {
        scanf("%d", &x);
        int v = kth(1, 1, N - 1, abs(x));
        add(1, 1, N - 1, v, -1);
    }
    printf("%d", findAnswer(1, 1, N - 1));
}