// 200 div 1 E
#include <iostream>
#include <fstream>
const int MAXN=100002;
        long long vc=100000000000000;

using namespace std;
long long a[MAXN],b[MAXN];
int n,m;
long long kq,maxt,dau,cuoi;

void nhap()
{
    int i;
    scanf("%d%d",&n,&m);
    for (i=1;i<=n;i++) {scanf("%I64d",&a[i]);maxt=max(maxt,a[i]);};
    for (i=1;i<=m;i++) {scanf("%I64d",&b[i]);maxt=max(maxt,b[i]);};
}

bool tinh(long long mid )
{
    int i,j,t;j=1;long long tg;
    for (i=1;i<=n;i++)
    {
        t=j;
        if (a[i]>=b[j])
        {
         tg=max((mid-(a[i]-b[j]))/2,mid-2*(a[i]-b[j]));
         while (b[j]-a[i]<=tg&&j<=m) j++;
         if (j>m) return(true);
        }
        else
        {
         while (b[j]-a[i]<=mid && j<=m) j++;
         if (j>m) return(true);
        };
    };
    return(false);
}

long long chat()
{
    long long mid;long long tg;
    tg=vc;
    dau=0;cuoi=maxt*2;
    while (dau<=cuoi)
    {
        mid=(dau+cuoi)/2;
        if (tinh(mid))
        {cuoi=mid-1;tg=mid;}
        else dau=mid+1;
    }
    return(tg);
}

void xl()
{
    int i,j;
    kq=chat();
    printf("%I64d",kq);
}

int main()
{
   // freopen("in.txt","r",stdin);
    nhap();
    xl();
    fclose(stdin);
    return 0;
}


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

using namespace std;

int n,m;
vector<long long> heads;
vector<long long> tracks;

bool test(long long d)
{
    int curr = 0;
//    cout << endl << d << endl << endl;
    for (int i=0; i<heads.size(); i++)
    {
        int best;
        if (abs(heads[i] - tracks[curr]) > d) return false;
        for (best=curr; ; best++)
        {
            if (best >= m) return true;
            long long dist = abs(heads[i] - tracks[best]) + (tracks[best] - tracks[curr]);
            long long dist2 = abs(heads[i] - tracks[curr]) + (tracks[best] - tracks[curr]);
//            cout << dist << " " << best << " " << i << endl;
            if (dist > d && dist2 > d) break;
        }
        curr = best;

        if (curr >= m) return true;
    }
    return false;
}

int main()
{

    scanf("%d %d", &n, &m);

    for (int i=0; i<n; i++)
    {
        long long p1;
        scanf("%I64d", &p1);
        heads.push_back(p1);
    }

    for (int i=0; i<m; i++)
    {
        long long p1;
        scanf("%I64d", &p1);
        tracks.push_back(p1);
    }

    long long lo = 0, hi = 100000000100;

//    if (test(23)) cout << "moze" << endl;

    while (lo < hi)
    {
        long long mid = (lo + hi) / 2;
        if (test(mid)) hi = mid; else lo = mid + 1;
//        cout << lo << " " << mid << " " << hi << endl;
    }

    cout << lo << endl;

    return 0;
}


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

using namespace std;

int n,m;
vector<long long> heads;
vector<long long> tracks;

bool test(long long d)
{
    int curr = 0;

    for (int i=0; i<heads.size(); i++)
    {
        long long dist = heads[i] - tracks[curr];
        long long rest = d - dist;
        if (dist > d) return false;
        if (dist <= d)
        {
            curr = max(lower_bound(tracks.begin(), tracks.end(), heads[i]) - tracks.begin(), lower_bound(tracks.begin(), tracks.end(), tracks[curr] + rest) - tracks.begin() );
        }
//        cout << curr << endl;
        if (curr >= m) return true;
    }
    return false;
}

int main()
{

    scanf("%d %d", &n, &m);

    for (int i=0; i<n; i++)
    {
        long long p1;
        scanf("%I64d", &p1);
        heads.push_back(p1);
    }

    for (int i=0; i<m; i++)
    {
        long long p1;
        scanf("%I64d", &p1);
        tracks.push_back(p1);
    }

    long long lo = 0, hi = 10000000010;

//    if (test(23)) cout << "moze" << endl;

    while (lo < hi)
    {
        long long mid = (lo + hi) / 2;
        if (test(mid)) hi = mid; else lo = mid + 1;
//        cout << lo << " " << mid << " " << hi << endl;
    }

    cout << lo-1 << endl;

    return 0;
}


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

using namespace std;

int n,m;
vector<long long> heads;
vector<long long> tracks;

bool test(long long d)
{
    int curr = 0;
//    cout << endl << d << endl << endl;
    for (int i=0; i<heads.size(); i++)
    {
        int best;
        for (best=curr; ; best++)
        {
            if (best >= m) return true;
            long long dist = abs(heads[i] - tracks[best]) + (tracks[best] - tracks[curr]);
            long long dist2 = abs(heads[i] - tracks[curr]) + (tracks[best] - tracks[curr]);
//            cout << dist << " " << best << " " << i << endl;
            if (dist > d && dist2 > d) break;
        }
        curr = best;

        if (curr >= m) return true;
    }
    return false;
}

int main()
{

    scanf("%d %d", &n, &m);

    for (int i=0; i<n; i++)
    {
        long long p1;
        scanf("%I64d", &p1);
        heads.push_back(p1);
    }

    for (int i=0; i<m; i++)
    {
        long long p1;
        scanf("%I64d", &p1);
        tracks.push_back(p1);
    }

    long long lo = 0, hi = 100000000100;

//    if (test(23)) cout << "moze" << endl;

    while (lo < hi)
    {
        long long mid = (lo + hi) / 2;
        if (test(mid)) hi = mid; else lo = mid + 1;
//        cout << lo << " " << mid << " " << hi << endl;
    }

    cout << lo << endl;

    return 0;
}


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

using namespace std;

int n,m;
vector<long long> heads;
vector<long long> tracks;

bool test(long long d)
{
    int curr = 0;

    for (int i=0; i<heads.size(); i++)
    {
        long long dist = heads[i] - tracks[curr];
        long long rest = d - dist;
        if (dist > d) return false;
        if (dist <= d)
        {
            curr = max(lower_bound(tracks.begin(), tracks.end(), heads[i]) - tracks.begin(), lower_bound(tracks.begin(), tracks.end(), tracks[curr] + rest) - tracks.begin() );
        }
//        cout << curr << endl;
        if (curr >= m) return true;
    }
    return false;
}

int main()
{

    scanf("%d %d", &n, &m);

    for (int i=0; i<n; i++)
    {
        long long p1;
        scanf("%I64d", &p1);
        heads.push_back(p1);
    }

    for (int i=0; i<m; i++)
    {
        long long p1;
        scanf("%I64d", &p1);
        tracks.push_back(p1);
    }

    long long lo = 0, hi = 100000000100;

//    if (test(23)) cout << "moze" << endl;

    while (lo < hi)
    {
        long long mid = (lo + hi) / 2;
        if (test(mid)) hi = mid; else lo = mid + 1;
//        cout << lo << " " << mid << " " << hi << endl;
    }

    cout << lo-1 << endl;

    return 0;
}


#include <algorithm>
#include <cstdio>
#include <iostream>
#include <set>
#include <cmath>
#include <cstring>
#include <vector>
using namespace std;
typedef long long ll;
const int MAX = int(1e5) + 5;

int N, M;
ll track[MAX], position[MAX];

bool f(ll T){
	int k = 0;

	for(int i = 0; i < N; i++){
		ll h = track[i], t = T;

		while(k < M && abs(position[k] - h) <= t){
			t -= abs(position[k] - h);
			h = position[k++];
		}

		if(k >= M) return true;
	}

	return false;
}

int main() {
	scanf("%d%d", &N, &M);
	for(int i = 0; i < N; i++)
		scanf("%I64d", track + i);
	for(int i = 0; i < M; i++)
		scanf("%I64d", position + i);

	ll lo = 0, hi = ll(1e11), mit;
	for(; lo < hi;){
		mit = (lo + hi) >> 1;
		if( f(mit) )   hi = mit;
		else 		   lo = mit + 1;
	}

	printf("%I64d\n", lo);

	return 0;
}


#include <algorithm>
#include <cstdio>
#include <iostream>
#include <set>
#include <cmath>
#include <cstring>
#include <vector>
using namespace std;
typedef long long ll;
const int MAX = int(1e5) + 5;

int N, M;
ll track[MAX], position[MAX];

#define nabs(X) ( (X)<0? -(X) : (X) )

bool f(ll T){
    int k = 0, next = 0;

    for(int i = 0; i < N; i++){
        ll h = track[i];
        while(next < M && position[next] <= h)
            next++;

        int left = k, right = next;

        while(left < M && nabs(h - position[k]) + nabs(position[k] - position[left]) <= T)
            left++;

        while(right < M && nabs(h - position[right]) + nabs(position[k] - position[right]) <= T)
            right++;

        if(left > k) left = max(left, next);
        right = right > next? right : -1;
        k = max(left, right);

        if(k >= M) return true;
    }

    return false;
}

int main() {
    scanf("%d%d", &N, &M);
    for(int i = 0; i < N; i++)
        scanf("%I64d", track + i);
    for(int i = 0; i < M; i++)
        scanf("%I64d", position + i);

    ll lo = 0, hi = ll(2e10), mit;
    for(; lo < hi;){
        mit = (lo + hi) >> 1;
        if( f(mit) )   hi = mit;
        else           lo = mit + 1;
    }

    printf("%I64d\n", lo);

    return 0;
}


#include <algorithm>
#include <cstdio>
#include <iostream>
#include <set>
#include <cmath>
#include <cstring>
#include <vector>
using namespace std;
typedef long long ll;
const int MAX = int(1e5) + 5;

int N, M;
ll track[MAX], position[MAX];

#define nabs(X) ( (X)<0? -(X) : (X) )

bool f(ll T){
    int k = 0, next = 0;

    for(int i = 0; i < N; i++){
        ll h = track[i];
        while(next < M && position[next] <= h)
            next++;

        int left = k, right = next;

        while(left < M && nabs(h - position[k]) + nabs(position[k] - position[left]) <= T)
            left++;

        while(right < M && nabs(h - position[right]) + nabs(position[k] - position[right]) <= T)
            right++;

        if(left > k) left = max(left, next);
        right = right > next? right : -1;
        k = max(left, right);

        if(k >= M) return true;
    }

    return false;
}

int main() {
    scanf("%d%d", &N, &M);
    for(int i = 0; i < N; i++)
        scanf("%I64d", track + i);
    for(int i = 0; i < M; i++)
        scanf("%I64d", position + i);

    ll lo = 0, hi = ll(3e10), mit;
    for(; lo < hi;){
        mit = (lo + hi) >> 1;
        if( f(mit) )   hi = mit;
        else           lo = mit + 1;
    }

    printf("%I64d\n", lo);

    return 0;
}


#include <algorithm>
#include <cstdio>
#include <iostream>
#include <set>
#include <cmath>
#include <cstring>
#include <vector>
using namespace std;
typedef long long ll;
const int MAX = int(1e5) + 5;

int N, M;
ll track[MAX], position[MAX];

#define nabs(X) ( (X)<0? -(X) : (X) )

bool f(ll T){
    int k = 0, next = 0;

    for(int i = 0; i < N; i++){
        ll h = track[i];
        while(next < M && position[next] <= h)
            next++;
        int left = k, right = next;

        while(left < M && nabs(h - position[k]) + nabs(position[k] - position[left]) <= T)
            left++;

        while(right < M && nabs(h - position[right]) + nabs(position[k] - position[right]) <= T)
            right++;

        right = right > next? right : -1;
        k = max(left, right);

        if(k >= M) return true;
    }

    return false;
}

int main() {
    scanf("%d%d", &N, &M);
    for(int i = 0; i < N; i++)
        scanf("%I64d", track + i);
    for(int i = 0; i < M; i++)
        scanf("%I64d", position + i);

    ll lo = 0, hi = ll(2e10), mit;
    for(; lo < hi;){
        mit = (lo + hi) >> 1;
        if( f(mit) )   hi = mit;
        else           lo = mit + 1;
    }

    printf("%I64d\n", lo);

    return 0;
}


#include <algorithm>
#include <cstdio>
#include <iostream>
#include <set>
#include <cmath>
#include <cstring>
#include <vector>
using namespace std;
typedef long long ll;
const int MAX = int(1e5) + 5;

int N, M;
ll track[MAX], position[MAX];

#define nabs(X) ( (X)<0? -(X) : (X) )

bool f(ll T){
    int k = 0, next = 0;

    for(int i = 0; i < N; i++){
        ll h = track[i];
        while(next < M && position[next] <= h)
            next++;

        if(nabs(h - position[k]) > T) return false;

        int left = k, right = next;

        while(left < M && nabs(h - position[k]) + nabs(position[k] - position[left]) <= T)
            left++;

        while(right < M && nabs(h - position[right]) + nabs(position[k] - position[right]) <= T)
            right++;

        left = max(left, next);
        right = right > next? right : -1;
        k = max(left, right);

        if(k >= M) return true;
    }

    return false;
}

int main() {
    scanf("%d%d", &N, &M);
    for(int i = 0; i < N; i++)
        scanf("%I64d", track + i);
    for(int i = 0; i < M; i++)
        scanf("%I64d", position + i);

    ll lo = 0, hi = ll(2e10), mit;
    for(; lo < hi;){
        mit = (lo + hi) >> 1;
        if( f(mit) )   hi = mit;
        else           lo = mit + 1;
    }

    printf("%I64d\n", lo);

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define pb push_back
#define IOS ios::sync_with_stdio(0), cin.tie(0)

using namespace std;

int n;

int main(){
	IOS;
	cin >> n;
	int arr[n];
	for(int i=0; i<n-1; i++){
		int in;
		cin >> in;
		arr[in-1]=in;
	}
	for(int i=0; i<n; i++){
		if(arr[i]==0){
			cout << i+1 <<'\n';
			return 0;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define pb push_back
#define IOS ios::sync_with_stdio(0), cin.tie(0)

using namespace std;

int n;

int main(){
	IOS;
	cin >> n;
	int arr[n];
	for(int i=0; i<n-1; i++){
		int in;
		cin >> in;
		arr[in-1]=in;
	}
	for(int i=0; i<n; i++){
		if(arr[i]==0){
			cout << i+1;
			return 0;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,a;
main(){
cin>>n;int b[n+1]={0};
for(int i=1;i<=n-1;i++)cin>>a,b[a]++;
for(int i=1;i<=n;i++)if(b[i]==0){cout<<i;return 0;}
}


#include<bits/stdc++.h>
using namespace std;
int n,a,m;
main(){
cin>>n;
for(int i=1;i<n;i++)cin>>a,m+=a;
cout<<(n*(n+1))/2-m;
}


#include<bits/stdc++.h>
using namespace std;
int n,a;
main(){
cin>>n;int b[n]={0};
for(int i=1;i<=n-1;i++)cin>>a,b[a]++;
for(int i=1;i<=n;i++)if(b[i]==0){cout<<i;return 0;}
}


#include<bits/stdc++.h>
using namespace std;
long long n,a,m;
main(){
cin>>n;
for(int i=1;i<n;i++)cin>>a,m+=a;
cout<<(n*(n+1))/2-m;
}


//DEEPANSHU SAXENA(saxenad765)
#include <bits/stdc++.h>
#define ll long long
#define array(x,n) (x,x+n)
#define vector(v) (v.begin(),v.end())
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define VECTOR(v) cout << '>' << #v << ':' ; vector_out(v);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ip(x) cin>>x
#define op(x) cout<<x<<endl
#define ops(x) cout<<x<<" "
#define odd(x) (x&1)
#define even(x) (!x&1)
#define fbei(i,x,y,z) for(ll i=x;i<=y;i+=z)
#define fbe(i,x,y) for(ll i=x;i<=y;i++)
#define f(i,n) for(ll i=0;i<n;i++)
#define pb push_back
#define mp(x,y) make_pair(x,y)
#define GCD(x,y) __gcd(x,y)
using namespace std;
//using codechef ide;
//Deepanshu Saxena
inline void filehandling()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}
vector<ll> vector_in(ll n)
{
	vector<ll> v(n);
	for(ll i=0;i<n;i++)
	cin>>v[i];
	return v;
}
void vector_out(vector<ll> v)
{
	for(ll i=0;i<v.size();i++)
	cout<<v[i]<<" ";
	cout<<endl;
}
ll vector_sum(vector<ll> v)
{
	ll sum;
	for(ll i=0;i<v.size();i++)
	sum+=v[i];
	return sum;
}
int main()
{
	fast
	filehandling();
    ll testcase=true;
    // ip(testcase);
    while(testcase--)
    {
        ll n;
        ip(n);
        ll a[n],hash[n+1]={0};
        f(i,n-1)
        {
            ip(a[i]);
            hash[a[i]]++;
        }
        fbe(i,1,n)
        {
            if(!hash[i])
            {
                op(i);
                break;
            }
        }
    }
}


//DEEPANSHU SAXENA(saxenad765)
#include <bits/stdc++.h>
#define ll long long
#define array(x,n) (x,x+n)
#define vector(v) (v.begin(),v.end())
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define VECTOR(v) cout << '>' << #v << ':' ; vector_out(v);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ip(x) cin>>x
#define op(x) cout<<x<<endl
#define ops(x) cout<<x<<" "
#define odd(x) (x&1)
#define even(x) (!x&1)
#define fbei(i,x,y,z) for(ll i=x;i<=y;i+=z)
#define fbe(i,x,y) for(ll i=x;i<=y;i++)
#define f(i,n) for(ll i=0;i<n;i++)
#define pb push_back
#define mp(x,y) make_pair(x,y)
#define GCD(x,y) __gcd(x,y)
using namespace std;
//using codechef ide;
//Deepanshu Saxena
inline void filehandling()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}
vector<ll> vector_in(ll n)
{
	vector<ll> v(n);
	for(ll i=0;i<n;i++)
	cin>>v[i];
	return v;
}
void vector_out(vector<ll> v)
{
	for(ll i=0;i<v.size();i++)
	cout<<v[i]<<" ";
	cout<<endl;
}
ll vector_sum(vector<ll> v)
{
	ll sum;
	for(ll i=0;i<v.size();i++)
	sum+=v[i];
	return sum;
}
int main()
{
	fast
	filehandling();
    ll testcase=true;
    // ip(testcase);
    while(testcase--)
    {
        ll n;
        ip(n);
        ll a[n],hash[n+1]={0};
        f(i,n)
        {
            ip(a[i]);
            hash[a[i]]++;
        }
        fbe(i,1,n+1)
        {
            if(!hash[i])
            op(i);
        }
    }
}


//DEEPANSHU SAXENA(saxenad765)
#include <bits/stdc++.h>
#define ll long long
#define array(x,n) (x,x+n)
#define vector(v) (v.begin(),v.end())
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define VECTOR(v) cout << '>' << #v << ':' ; vector_out(v);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ip(x) cin>>x
#define op(x) cout<<x<<endl
#define ops(x) cout<<x<<" "
#define odd(x) (x&1)
#define even(x) (!x&1)
#define fbei(i,x,y,z) for(ll i=x;i<=y;i+=z)
#define fbe(i,x,y) for(ll i=x;i<=y;i++)
#define f(i,n) for(ll i=0;i<n;i++)
#define pb push_back
#define mp(x,y) make_pair(x,y)
#define GCD(x,y) __gcd(x,y)
using namespace std;
//using codechef ide;
//Deepanshu Saxena
inline void filehandling()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}
vector<ll> vector_in(ll n)
{
	vector<ll> v(n);
	for(ll i=0;i<n;i++)
	cin>>v[i];
	return v;
}
void vector_out(vector<ll> v)
{
	for(ll i=0;i<v.size();i++)
	cout<<v[i]<<" ";
	cout<<endl;
}
ll vector_sum(vector<ll> v)
{
	ll sum;
	for(ll i=0;i<v.size();i++)
	sum+=v[i];
	return sum;
}
int main()
{
	fast
	filehandling();
    ll testcase=true;
    // ip(testcase);
    while(testcase--)
    {
        ll n;
        ip(n);
        ll a[n],hash[n+1]={0};
        f(i,n)
        {
            ip(a[i]);
            hash[a[i]]++;
        }
        fbe(i,1,n+1)
        {
            if(!hash[i])
            return op(i),0;
        }
    }
}


//DEEPANSHU SAXENA(saxenad765)
#include <bits/stdc++.h>
#define ll long long
#define array(x,n) (x,x+n)
#define vector(v) (v.begin(),v.end())
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define VECTOR(v) cout << '>' << #v << ':' ; vector_out(v);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ip(x) cin>>x
#define op(x) cout<<x<<endl
#define ops(x) cout<<x<<" "
#define odd(x) (x&1)
#define even(x) (!x&1)
#define fbei(i,x,y,z) for(ll i=x;i<=y;i+=z)
#define fbe(i,x,y) for(ll i=x;i<=y;i++)
#define f(i,n) for(ll i=0;i<n;i++)
#define pb push_back
#define mp(x,y) make_pair(x,y)
#define GCD(x,y) __gcd(x,y)
using namespace std;
//using codechef ide;
//Deepanshu Saxena
inline void filehandling()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}
vector<ll> vector_in(ll n)
{
	vector<ll> v(n);
	for(ll i=0;i<n;i++)
	cin>>v[i];
	return v;
}
void vector_out(vector<ll> v)
{
	for(ll i=0;i<v.size();i++)
	cout<<v[i]<<" ";
	cout<<endl;
}
ll vector_sum(vector<ll> v)
{
	ll sum;
	for(ll i=0;i<v.size();i++)
	sum+=v[i];
	return sum;
}
int main()
{
	fast
	filehandling();
    ll testcase=true;
    // ip(testcase);
    while(testcase--)
    {
        ll n;
        ip(n);
        ll a[n],hash[n+1]={0};
        f(i,n)
        {
            ip(a[i]);
            hash[a[i]]++;
        }
        fbe(i,1,n)
        {
            if(!hash[i])
            return op(i),0;
        }
    }
}


#include<stdio.h>
int main()

{
    long long n;
    scanf("%lld",&n);
    long long a[n-1];
    long long i;
    long long int total=0;
    for(i =0;i<n-1;i++)
    {
        scanf("%lld",&a[i]);
        total=total+a[i];
    }
    long long sum;
    sum = (n*(n+1))/2;
    long long episode_number = sum-total;
    printf("%lld",episode_number);
    return 0;
}


#include<stdio.h>
void main()

{
    long long n;
    scanf("%lld",&n);
    long long a[n-1];
    long long i;
    long long int total;
    for(i =0;i<n-1;i++)
    {
        scanf("%lld",&a[i]);
        total=total+a[i];
    }
    long long sum;
    sum = (n*(n+1))/2;
    long long episode_number = sum-total;
    printf("%lld",episode_number);

}


#include<stdio.h>
int main()

{
    long long n;
    scanf("%lld",&n);
    long long a[n-1];
    long long i;
    long long int total;
    for(i =0;i<n-1;i++)
    {
        scanf("%lld",&a[i]);
        total=total+a[i];
    }
    long long sum;
    sum = (n*(n+1))/2;
    long long episode_number = sum-total;
    printf("%lld",episode_number);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		if(a[i]!=i){
			cout<<i;
			cout<<" ";
			i++;
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n==0){
		cout<<"0";
		return 0;
	}
	if(n==1){
		cout<<1;
		return 0;
	}
	int a[n+1];
	for(int i=1;i<n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		if(a[i]!=i){
			cout<<i;
			return 0;
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n==0){
		cout<<"0";
		return 0;
	}
	if(n==1){
		cout<<"1";
		return 0;
	}
	int a[n+1];
	int s=0;
	int t=0;
	for(int i=1;i<=n;i++){
		s+=i;
	}
	for(int i=1;i<n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=1;i<n;i++){
		t+=a[i];
	}
	cout<<s-t;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n==0){
		cout<<"0";
		return 0;
	}

	int a[n+1];
	for(int i=1;i<n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		if(a[i]!=i){
			cout<<i;
			return 0;
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		if(a[i]!=i){
			cout<<i;
			return 0;
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int>v;
    for(int i=0;i<n-1;i++){
        int a;
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());

    for(int i=1;i<=10;i++){
        if(v[i-1]!=i){
            cout << i <<endl;
            return 0;
        }
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int>v;
    for(int i=0;i<n-1;i++){
        int a;
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());

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

    return 0;
}


#include<iostream>
using namespace std;int main(){int n,x,s=0;cin>>n;for(int i=0;i<n;++i){cin>>x;s+=x;}cout<<(n*(n+1))/2-s;return 0}


#include<iostream>
using namespace std;int main(){int n,x,s=0;cin>>n;for(int i=0;i<n;++i){cin>>x;s+=x;}cout<<(n*(n+1))/2-s;return 0;}


#include<iostream>
using namespace std;int main(){int n,x,s=0;cin>>n;for(int i=0;i<n-1;++i){cin>>x;s+=x;}cout<<(n*(n+1))/2-s;return 0;}


#include<iostream>
using namespace std;int main(){ios_base::sync_with_stdio(false);cin.tie(NULL);long long n,x,s=0;cin>>n;for(int i=0;i<n-1;++i){cin>>x;s+=x;}cout<<(n*(n+1))/2-s;return 0;}


#include <iostream>
#include <algorithm>
using namespace std;

typedef long long ll;

int main() {
	int n, i, ans = 0, a;
	cin >> n;
	int e[n];
	a = n-1;
	for(i = 0; i < n - 1; i++) {
		cin >> e[i];
	}
	sort(e, e + a);
	do {
		if(n != e[a-1]) {
			ans = n;
			break;
		} else a--;
	} while(n--);
	cout << ans << endl;

	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

typedef long long ll;

int main() {
	int n, i, ans = 0, a;
	cin >> n;
	int e[n];
	a = n;
	for(i = 0; i < n - 1; i++) {
		cin >> e[i];
	}
	sort(e, e + n);
	do {
		if(n != e[a-2]) {
			ans = n;
			break;
		} else a--;
	} while(n--);
	cout << ans << endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n;
    cin>>n;
    int a[n-1];
    for(int i=0;i<n-1;i++)
        cin>>a[i];
    if(n==2)
        if(a[0]==1)
            {cout<<2;return 0;}
        else
            {cout<<1;return 0;}
    sort(a,a+n-1);
    if(a[0]!=1)
        {cout<<1;return 0;}
    for(int k=0;k<n;k++)
        if(a[k]!=a[k+1]-1)
            {cout<<k+2;return 0;}
    cout<<n;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int a[n-1];
for(int i=0;i<n-1;i++)
cin>>a[i];
if(n>2)
{
sort(a,a+(n-1));
for(int i=0;i<n-1;i++)
{
if(a[i+1]-a[i]!=1)
{
cout<<a[i]+1;
break;
}
}
}
else if(n==2)
{
if(a[0]==2)
cout<<1;
else if(a[0]==1)
cout<<2;
}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int a[n-1];
for(int i=0;i<n-1;i++)
cin>>a[i];
sort(a,a+(n-1));
for(int i=0;i<n-1;i++)
{
if(a[i+1]-a[i]!=1)
{
cout<<a[i]+1;
break;
}
}
    return 0;
}


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

int main ()
{
    int n, tem, i;
    cin >> n;
    int arr[n-1]={0};
    for (int i=0; i<n-1; i++)
        cin >> arr[i];
    sort(arr,arr+n-1);
    for (i=0; i<n-2; i++)
        if (arr[i]+1!=arr[i+1])
            break;
    cout << arr[i]+1;
    return 0;
}


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

int main ()
{
    int n, tem, i;
    cin >> n;
    int arr[n]={0};
    for (int i=0; i<n-1; i++)
    {
        cin >> tem;
        arr[tem-1]++;
    }
    for (i=0; i<n; i++)
        if (!arr[i])
            break;
    cout << i+1;
    return 0;
}


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

int main ()
{
    int n, tem, i;
    cin >> n;
    int arr[n-1]={0};
    for (int i=0; i<n-1; i++)
        cin >> arr[i];
    sort(arr,arr+n-1);
    for (i=0; i<n-2; i++)
        if (arr[i]+1!=arr[i+1])
            break;
    if (arr[i]+1>n)
        cout << 1;
    else
        cout << arr[i]+1;
    return 0;
}


#include<iostream>
#include<cctype>
#include<stdlib.h>
#include<math.h>
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
using namespace std;

int main() {
	fastio;
	long n;
	cin>>n;
	vector<long>v;
	for(long i=0;i<n-1;i++)
    {
        long in;
        cin>>in;
        v.push_back(in);
    }
    long i;
    sort(v.begin(),v.end());
    for(i=0;i<n-1;i++)
    {
        if(v[i]!=i+1)
        {
            cout<<i+1;
            break;
        }
    }
    if(i==n-1)
        cout<<n;
	return 0;
}


#include<iostream>
#include<cctype>
#include<stdlib.h>
#include<math.h>
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
using namespace std;

int main() {
	fastio;
	long n;
	cin>>n;
	vector<long>v;
	for(long i=0;i<n-1;i++)
    {
        long in;
        cin>>in;
        v.push_back(in);
    }
    for(long i=1;i<=n;i++)
    {
        if(find(v.begin(),v.end(),i)==v.end()){
            cout<<i;
            break;
        }
    }
	return 0;
}


#include<iostream>
#include<cctype>
#include<stdlib.h>
#include<math.h>
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
using namespace std;

int main() {
	fastio;
	long n;
	cin>>n;
	vector<long>v;
	for(long i=0;i<n-1;i++)
    {
        long in;
        cin>>in;
        v.push_back(in);
    }
    for(long i=1;i<=n;i++)
    {
        if(find(v.begin(),v.end(),i)==v.end())
            cout<<i;
    }
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i = a; i < n; i++)
#define per(i,a,n) for (int i = n - 1; i >= a; i--)
#define pb(v, n) v.push_back(n)

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

    int size;
    cin >> size;

    int fsum = 0;
    rep(i, 0, size - 1) {
        int num;
        cin >> num;
        fsum += num;
    }
    int sum = 0;
    rep(i, 1, size + 1) {
        sum += i;
    }
    cout << sum - fsum << '\n';

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i = a; i < n; i++)
#define per(i,a,n) for (int i = n - 1; i >= a; i--)
#define pb(v, n) v.push_back(n)

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

    int size;
    cin >> size;

    vector<int> v(size - 1);
    rep(i, 0, size - 1) {
        cin >> v[i];
    }

    rep(i, 1, size + 1) {
        if (!count(v.begin(), v.end(), i)) {
            cout << i << '\n';
            break;
        }
    }

    return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BP(n) __builtin_popcount(n)
#define bs(v,x) binary_search(all(v),x)
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(j,n) for (j=i+1;j<n;j++)
#define Unique(v) vector<int>::iterator it; sort(all(v)); it= unique(all(v)); v.resize(distance(v.begin(),it))
#define mod 1000000007
#define PI acos(-1.0)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
using namespace std;
void input(vector<ll>& v,ll n){ ll i,io; rep(i,n) { cin>>io; v.pb(io);} }
/*void output(vector<int> v) { int i; rep(i,v.size()) cout<<v.at(i)<<" "; }
map<int,int>  frequency(vector<int> v){ int i; map<int,int> m; rep (i,v.size()) {  if (m.find(v[i])==m.end()) m.insert({v.at(i),1}); else m[v.at(i)]++; } return m; }
bool perfsq(ll n){ return (ceil(sqrt(n))==floor(sqrt(n))); }
bool ispower2(int n) { if (n&(n-1)==0) return true; else return false; }
bool binary_pred(int a,int b){ return a==b; }*/
int main() {
	fastio;
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	ll n;
	cin>>n;
	vector<ll> v;
	input(v,n-1);
	ll sum = n*(n+1)/2;
	ll sum1 = accumulate(all(v),0);
	cout<<sum - sum1<<endl;
}


#include<bits/stdc++.h>
#include<iostream>
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BP(n) __builtin_popcount(n)
#define bs(v,x) binary_search(all(v),x)
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(j,n) for (j=i+1;j<n;j++)
#define Unique(v) vector<int>::iterator it; sort(all(v)); it= unique(all(v)); v.resize(distance(v.begin(),it))
#define mod 1000000007
#define PI acos(-1.0)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
using namespace std;
void input(vector<int>& v,int n){ int i; int io; rep(i,n) { cin>>io; v.pb(io);} }
void output(vector<int> v) { int i; rep(i,v.size()) cout<<v.at(i)<<" "; }
map<int,int>  frequency(vector<int> v){ int i; map<int,int> m; rep (i,v.size()) {  if (m.find(v[i])==m.end()) m.insert({v.at(i),1}); else m[v.at(i)]++; } return m; }
/*bool perfsq(ll n){ return (ceil(sqrt(n))==floor(sqrt(n))); }
bool ispower2(int n) { if (n&(n-1)==0) return true; else return false; }
bool binary_pred(int a,int b){ return a==b; }*/
int main() {
	fastio;
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	int n;
	cin>>n;
	vector<int> v;
	input(v,n-1);
	ll sum = n*(n+1)/2;
	ll sum1 = accumulate(all(v),0);
	cout<<sum - sum1<<endl;
}


#include<bits/stdc++.h>
#include<iostream>
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BP(n) __builtin_popcount(n)
#define bs(v,x) binary_search(all(v),x)
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(j,n) for (j=i+1;j<n;j++)
#define Unique(v) vector<int>::iterator it; sort(all(v)); it= unique(all(v)); v.resize(distance(v.begin(),it))
#define mod 1000000007
#define PI acos(-1.0)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
using namespace std;
void input(vector<ll>& v,ll n){ ll i,io; rep(i,n) { cin>>io; v.pb(io);} }
void output(vector<int> v) { int i; rep(i,v.size()) cout<<v.at(i)<<" "; }
map<ll,ll>  frequency(vector<ll> v){ ll i; map<ll,ll> m; rep (i,v.size()) {  if (m.find(v[i])==m.end()) m.insert({v.at(i),1}); else m[v.at(i)]++; } return m; }
/*bool perfsq(ll n){ return (ceil(sqrt(n))==floor(sqrt(n))); }
bool ispower2(int n) { if (n&(n-1)==0) return true; else return false; }
bool binary_pred(int a,int b){ return a==b; }*/
int main() {
	fastio;
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	ll n,i;
	cin>>n;
	vector<ll> v;
	vector<ll> orig;
	for (i=1;i<=n;i++)
		orig.pb(i);
	input(v,n-1);
	rep(i,n)
		v.pb(orig[i]);
	map<ll,ll> m;
	m = frequency(v);
	for (auto& it : m) {
		if (it.second == 1) {
			cout<<it.first<<endl;
			break;
		}
	}
}


#include <iostream>
using namespace std;
int main() {
    int n, tmp;
    cin >> n;
    long long sum = n * (n + 1LL) >> 1;
    for (int i = 1; i < n; ++i) {
        cin >> tmp;
        sum -= tmp;
    }
    cout << sum;
    return 0;
}


#include <iostream>
using namespace std;
int main() {
    int n, sum, tmp;
    sum = 0;
    cin >> n;
    for (int i = 1; i < n; ++i) {
        cin >> tmp;
        sum += tmp;
    }
    cout << n * (n + 1) / 2 - sum;
    return 0;
}


#include <iostream>
using namespace std;
#define ll long long

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;
    ll ans = (n*(n+1LL))/2LL, sum = 0;
    for(int i = 0; i < n-1; i++) {
        int k; cin >> k;
        sum += k;
    }
    cout << ans-sum << "\n";
    return 0;
}


#include <iostream>
using namespace std;
#define ll long long

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;
    ll ans = (n*(n+1LL))/2LL, sum = 0;
    for(int i = 0; i < n; i++) {
        int k; cin >> k;
        sum += k;
    }
    cout << ans-sum << "\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  int a, b;
  cin >> a;
  a = a * (a + 1) / 2;
  while (cin >> b) a -= b;
  cout << a;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  int64_t a, b;
  cin >> a;
  a = a * (a + 1) / 2;
  while (cin >> b) a -= b;
  cout << a;
}


#include <algorithm>
#include <iostream>
using namespace std;
int a[100005];

int main()
{
    int n; cin>>n;
    for(int i=1;i<=n-1;i++) cin>>a[i];
    sort(a+1,a+n);
    a[n]=n+1;
    for(int i=0;i<=n-1;i++)
        if(a[i+1]-a[i]==2) {cout<<i+1;break;}

return 0;
}


#include <algorithm>
#include <iostream>
using namespace std;
bool a[100005]={false};

int main()
{
    int n,x; cin>>n;
    for(int i=1;i<=n-1;i++)
    {  cin>>x;
       a[x]=true;
    }
    for(int i=1;i<=n;i++)
        if(a[i]==false) {cout<<i;break;}

return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int arr[n];
for(int i=0;i<n-1;i++)cin>>arr[i];
sort(arr,arr+n-1);
for(int i=0;i<n-1;i++){
    if(arr[i]!=i+1){
        cout<<i+1;
        return 0;
    }
}
cout<<n;
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int arr[n];
for(int i=0;i<n-1;i++)cin>>arr[i];
sort(arr,arr+n);
for(int i=0;i<n-1;i++){
    if(arr[i]!=i+1){
        cout<<i+1;
        return 0;
    }
}
cout<<n;
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int arr[n];
for(int i=0;i<n-1;i++)cin>>arr[i];
sort(arr,arr+n);
for(int i=0;i<n-1;i++){
    if(arr[i]!=i+1){
        cout<<i+1;
        return 0;
    }
}
cout<<arr[n-1];
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int arr[n];
for(int i=0;i<n-1;i++)cin>>arr[i];
sort(arr,arr+n);
for(int i=0;i<n;i++){
    if(arr[i]!=i+1){
        cout<<i+1;
        return 0;
    }
}
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int arr[n]={100000};
for(int i=0;i<n-1;i++)cin>>arr[i];
sort(arr,arr+n);
for(int i=0;i<n;i++){
    if(arr[i]!=i+1){
        cout<<i+1;
        return 0;
    }
}
return 0;
}


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

int main()
{
	int t;
	cin >> t;
	long long n[t];
	long long sum=0;
	for(int i=0; i<t-1; ++i)
	{
		cin >> n[i];
		sum+=n[i];
	}
	long long d=t*(t+1)/2-sum;
	cout << d << endl;
}


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

int main()
{
	int t;
	cin >> t;
	int n[t];
	long long sum=0;
	for(int i=0; i<t-1; ++i)
	{
		cin >> n[i];
		sum+=n[i];
	}
	cout << t*(t+1)/2-sum << endl;
}


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

int main()
{
	long long t;
	cin >> t;
	long long n[t];
	long long sum=0;
	for(int i=0; i<t-1; ++i)
	{
		cin >> n[i];
		sum+=n[i];
	}
	long long d=t*(t+1)/2-sum;
	cout << d << endl;
}


#include <bits/stdc++.h>
//1 + 1 == 3(?!);
//in the name of god;
using namespace std;
typedef long long ll;
#define pb push_back
 ll ind;
 int main(){
 	ll n;
 	cin >> n;
 	ll x[n] = {0};
 	ll qp[n + 1000];
 	for ( ll i = 0; i < n - 1; ++i )cin >> qp[i], ++x[qp[i]];
 	for ( ll i = 1; i < n; ++i ){
 		if(x[i] == 0){
 			cout << i;
 			return 0;
	    }
    }
 }


#include <bits/stdc++.h>
//1 + 1 == 3(?!);
//in the name of god;
using namespace std;
typedef long long ll;
#define pb push_back
 ll ind;
 int main(){
 	ll n;
 	cin >> n;
 	ll x[n + 1] = {0};
 	ll qp[n + 1000];
 	for ( ll i = 0; i < n - 1; ++i )cin >> qp[i], ++x[qp[i]];
 	for ( ll i = 1; i <= n; ++i ){
 		if(x[i] == 0){
 			cout << i;
 			return 0;
	    }
    }
 }


#include <bits/stdc++.h>
//1 + 1 == 3(?!);
//in the name of god;
using namespace std;
typedef long long ll;
#define pb push_back
 ll ind;
 int main(){
 	ll n;
 	cin >> n;
 	ll x[n] = {0};
 	ll qp[n + 1000];
 	for ( ll i = 0; i < n - 1; ++i )cin >> qp[i], ++x[qp[i]];
 	for ( ll i = 1; i < n; ++i ){
 		if(x[i] == 0){
 			cout << i;
 			return 0;
	    }


#include <bits/stdc++.h>
using namespace std;
#define llp(i,x,n) for(i=x;i<n;i++)
#define ll long long int
#define pb push_back
#define mp make_pair
#define fe first
#define se second
#define all(x) x.begin(), x.end()
#define clr(x,y) memset(x, y, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pl> vpll;
#define umap unordered_map
#define mset multi_set
#define mmap multi_map
#define pqu priority_queue
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define time srand(chrono::high_resolution_clock::now().time_since_epoch().count())
#define maxi(a,b,c) max(a,max(b,c))

int main()
{
fastio;
time;
 int n,i,s=0;
 cin>>n;
 int a;
 llp(i,0,n)cin>>a,s+=a;
 cout<<((n*(n+1))/2)-s;

 return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define llp(i,x,n) for(i=x;i<n;i++)
#define ll long long int
#define pb push_back
#define mp make_pair
#define fe first
#define se second
#define all(x) x.begin(), x.end()
#define clr(x,y) memset(x, y, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pl> vpll;
#define umap unordered_map
#define mset multi_set
#define mmap multi_map
#define pqu priority_queue
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define time srand(chrono::high_resolution_clock::now().time_since_epoch().count())
#define maxi(a,b,c) max(a,max(b,c))

int main()
{
fastio;
time;
 ll n,i,s=0;
 cin>>n;
 int a;
 llp(i,0,n-1)cin>>a,s+=a;
 cout<<((n*(n+1))/2)-s;

 return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define llp(i,x,n) for(i=x;i<n;i++)
#define ll long long int
#define pb push_back
#define mp make_pair
#define fe first
#define se second
#define all(x) x.begin(), x.end()
#define clr(x,y) memset(x, y, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pl> vpll;
#define umap unordered_map
#define mset multi_set
#define mmap multi_map
#define pqu priority_queue
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define time srand(chrono::high_resolution_clock::now().time_since_epoch().count())
#define maxi(a,b,c) max(a,max(b,c))

int main()
{
fastio;
time;
 int n,i,s=0;
 cin>>n;
 int a;
 llp(i,0,n-1)cin>>a,s+=a;
 cout<<((n*(n+1))/2)-s;

 return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define llp(i,x,n) for(i=x;i<n;i++)
#define ll long long int
#define pb push_back
#define mp make_pair
#define fe first
#define se second
#define all(x) x.begin(), x.end()
#define clr(x,y) memset(x, y, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pl> vpll;
#define umap unordered_map
#define mset multi_set
#define mmap multi_map
#define pqu priority_queue
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define time srand(chrono::high_resolution_clock::now().time_since_epoch().count())
#define maxi(a,b,c) max(a,max(b,c))

int main()
{
fastio;
time;
 int n,i,s=0;
 cin>>n;
 int a;
 llp(i,0,n-1)cin>>a,s+=a;
 cout<<s<<"\n";
 cout<<((n*(n+1))/2)-s;

 return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define llp(i,x,n) for(i=x;i<n;i++)
#define ll long long int
#define pb push_back
#define mp make_pair
#define fe first
#define se second
#define all(x) x.begin(), x.end()
#define clr(x,y) memset(x, y, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pl> vpll;
#define umap unordered_map
#define mset multi_set
#define mmap multi_map
#define pqu priority_queue
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define time srand(chrono::high_resolution_clock::now().time_since_epoch().count())
#define maxi(a,b,c) max(a,max(b,c))

int main()
{
fastio;
time;
 int n,i,s=0;
 cin>>n;
 int a;
 llp(i,0,n)cin>>a,s+=a;
 cout<<n*(n+1)/2-s;

 return 0;
}


#include <cstdio>

using namespace std;

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

	k = n & 3;
	if (k == 0) k = n;
	else if (k == 2) k = n + 1;
	else if (k == 3) k = 0;

	while (--n)
	{
		scanf("%d", &a);
		k ^= a;
	}
	printf("%d", k);
}


#include <cstdio>

using namespace std;

long long int typedef li;

int main()
{
	int a,n;
	li k; scanf("%d", &n);
	k = (li)n * ((li)n + 1) / 2;
	while (--n)
	{
		scanf("%d", &a);
		k -= a;
	}
	printf("%d", k);
}


#include <cstdio>

using namespace std;

int main()
{
	int a,n;
	long int k; scanf("%d", &n);
	k = (long)n * ((long)n + 1) / 2;
	while (--n)
	{
		scanf("%d", &a);
		k -= a;
	}
	printf("%d", k);
}


#include <cstdio>

using namespace std;

long int typedef li;

int main()
{
	int a,n;
	li k; scanf("%d", &n);
	k = (li)n * ((li)n + 1) / 2;
	while (--n)
	{
		scanf("%d", &a);
		k -= a;
	}
	printf("%d", k);
}


#import <cstdio>

using namespace std;

int main()
{
	int a,n;
	li k; scanf("%d", &n);
	k = (long)n * ((long)n + 1) / 2;
	while (--n)
	{
		scanf("%d", &a);
		k -= a;
	}
	printf("%d", k);
}


#include <cstdio>

using namespace std;

int main()
{
	int a,n;
	li k; scanf("%d", &n);
	k = (long)n * ((long)n + 1) / 2;
	while (--n)
	{
		scanf("%d", &a);
		k -= a;
	}
	printf("%d", k);
}


#include<bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define ff find_first_of
#define fl find_last_of
#define all(s) (s).begin(),(s).end()
#define rall(s) (s).rbegin(),(s).rend()
#define bs(x) (bitset<18>(x)).to_string()
#define sep ios::sync_with_stdio(0),cin.tie(0)
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	vector<int>a(n);
	for(auto &x:a) cin>>x;
	sort(all(a));
	for(int i=0;i<n-1;i++)
		if(i+1!=a[i]) return cout<<i+1,0;

}


#include<bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define ff find_first_of
#define fl find_last_of
#define all(s) (s).begin(),(s).end()
#define rall(s) (s).rbegin(),(s).rend()
#define bs(x) (bitset<18>(x)).to_string()
#define sep ios::sync_with_stdio(0),cin.tie(0)
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	vector<int>a(n-1);
	for(auto &x:a) cin>>x;
	sort(all(a));
	for(int i=0;i<n;i++)
		if(i+1!=a[i]) return cout<<i+1,0;

}


#include<bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define ff find_first_of
#define fl find_last_of
#define all(s) (s).begin(),(s).end()
#define rall(s) (s).rbegin(),(s).rend()
#define bs(x) (bitset<18>(x)).to_string()
#define sep ios::sync_with_stdio(0),cin.tie(0)
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	vector<int>a(n-1);
	for(auto &x:a) cin>>x;
	sort(all(a));
	for(int i=0;i<n-1;i++)
		if(i+1!=a[i]) return cout<<i+1,0;

}


#include <iostream>
#include <cmath>
#include <string>
const int N = 100000;
#define ull unsigned long long
using namespace std;
int main(){
int p[N];
int n;
cin >> n;
for(int i = 1 ; i < n; i++){
	int t;
	cin >> t;
	p[t] = 1;
}
for(int i = 1 ; i < n + 1; i++){
	if(p[i] == 0){cout << i;}
}
}


#include <iostream>
#include <cmath>
#include <string>

#define ull unsigned long long
const ull N = 1000001;
using namespace std;
int main(){
ull p[N];
ull n;
cin >> n;
for(int i = 1 ; i < n; i++){
	int t;
	cin >> t;
	p[t] = 1;
}
for(int i = 1 ; i < n + 1; i++){
	if(p[i] == 0){cout << i;}
}
}


#include <iostream>
#include <cmath>
#include <string>

#define ull unsigned long long
const ull N = 100000;
using namespace std;
int main(){
ull p[N];
ull n;
cin >> n;
for(int i = 1 ; i < n; i++){
	int t;
	cin >> t;
	p[t] = 1;
}
for(int i = 1 ; i < n + 1; i++){
	if(p[i] == 0){cout << i;}
}
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int e,f,s=0;
    cin >> e;
    for (int i = 0; i < e-1; i++)
    {
        cin >> f;
        s += f;
    }
    cout << e*(1+e)/2-s;

}


#include <bits/stdc++.h>

using namespace std;

int main() {
    long long e,f,s=0;
    cin >> e;
    for (int i = 0; i < e-1; i++)
    {
        cin >> f;
        s += f;
    }
    cout << e*(1+e)/2-s;

}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int ar[n-1],ans[n]={0};
    for(int i=0;i<n-1;i++){
        cin >> ar[i];
        ans[ar[i]-1]=1;
    }
    for(int i=0;i<n;i++){
        if(ans[i]==0){
            cout<<i+1;
            break;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++)
    cin>>ar[i];
    sort(ar,ar+n);
    for(int i=0;i<n;i++){
        if(ar[i]+1 != ar[i+1]){
        cout<<ar[i]+1;
        break;
        }
    }

}


#include "bits/stdc++.h"
#define ll long long
#define ld long double
using namespace std;

int main()
{
    ll n;
     cin >> n;
     vector<ll> vec(n,true);
     ll z =0;
     for(int i = 0; i < n-1; i++)
     {
         cin >> z;
         vec[z-1] = false;
     }
     for(auto z : vec)
     {
         if(z == true)
         {
             cout << z+1;
             break;
         }
     }
}


#include "bits/stdc++.h"
#define ll long long
#define ld long double
using namespace std;

int main()
{
    ll n;
     cin >> n;
     vector<ll> vec(n,true);
     ll z =0;
     for(int i = 0; i < n-1; i++)
     {
         cin >> z;
         vec[z-1] = false;
     }
     for(int i = 0; i < n; i++)
     {
         if(z == true)
         {
             cout << i+1;
             break;
         }
     }
}


#include "bits/stdc++.h"
#define ll long long
#define ld long double
using namespace std;

int main()
{
    ll n;
     cin >> n;
     vector<ll> vec(n,true);
     ll z =0;
     for(int i = 0; i < n-1; i++)
     {
         cin >> z;
         vec[z-1] = false;
     }
     for(int i = 0; i < n; i++)
     {
         if(vec[i])
         {
             cout << i+1;
             break;
         }
     }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,total,value,sum=0;
    cin>>n;
    total = (n*(n+1))/2;
    for(int i=0;i<n-1;i++){
        cin>>value;
        sum += value;
    }
    cout<<total-sum<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,arr[100005]={0},value;
    cin>>n;
    for(int i=0;i<n-1;i++){
        cin>>value;
        arr[value-1] = 1;
    }
    for(int i=0;i<n;i++){
        if(arr[i]==0){
            cout<<i+1<<endl;
            break;
        }
    }
    return 0;
}


#include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int m, k=0;
	for(int i=0; i<n-1; i++){
		cin>>m;
		k+=m;
	}
	cout<<n*(n+1)/2-k;
	return 0;
}


#include <iostream>
using namespace std;
int main(){
	long long int n;
	cin>>n;
	long long int m, k=0;
	for(int i=0; i<n-1; i++){
		cin>>m;
		k+=m;
	}
	cout<<n*(n+1)/2-k;
	return 0;
}


#include <Graphics>

int main()
{
    // создаём окно
    sf::RenderWindow app(sf::VideoMode(800, 600, 32), "Hello World - SFML");

    // основной цикл
    while (app.isOpen())
    {
        // проверяем события (нажатие кнопки, закрытие окна и т.д.)
        sf::Event event;
        while (app.pollEvent(event))
        {
            // если событие "закрытие окна":
            if (event.type == sf::Event::Closed)
                 // закрываем окно
                app.close();
        }

        // очищаем экран и заливаем его синим цветом
        app.clear(sf::Color(0,0,255));

        // отображаем на экран
        app.display();
    }

    return 0;
}


#include <iostream>
using namespace std;
int main(){
	long long int n;
	cin>>n;
	int m, k=0;
	for(int i=0; i<n-1; i++){
		cin>>m;
		k+=m;
	}
	cout<<n*(n+1)/2-k;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false),cin.tie(0);

	int n,x;
	cin>>n;
	vector<int>Dp(n);

	for(int i=1;i<n;i++)
		cin>>x,Dp[x-1]++;

	for(int i=1;i<=n;i++)
		if(!Dp[i-1])return cout<<i,0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false),cin.tie(0);

	int n,x;
	cin>>n;
	vector<int>Dp(n);

	for(int i=1;i<n;i++)
		cin>>x,Dp[x-1]++;

	for(int i=1;i<=10;i++)
		if(!Dp[i-1])return cout<<i,0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false),cin.tie(0);

	int n,x;
	cin>>n;
	vector<int>Dp(n);

	for(int i=1;i<n;i++)
		cin>>x,Dp[x-1]++;

	for(int i=1;i<=10;i++)
		if(!Dp[i-1]) cout<<i;
}


# include <bits/stdc++.h>
using namespace std;
int n, a;
vector <int> vc, ve;
int main (){
    cin >> n;
    for (int i = 1; i <= n - 1; i ++){
        cin >> a;
        vc.push_back(a);
    }
    for (int i = 1; i < n; i ++){
        ve.push_back(i);
    }
    sort (vc.begin(), vc.end());
    for (int i = 1; i <= n; i ++){
        if (vc[i] != ve[i]){
            cout << ve[i];
            exit (0);
        }
    }
}


# include <bits/stdc++.h>
using namespace std;
int n, a, cnt, bnt;
int main (){
    cin >> n;
    for (int i = 1; i <= n - 1; i ++){
        cin >> a;
        cnt += a;
    }
    for (int i = 1; i <= n; i ++){
        bnt += i;
    }
    cout << bnt - cnt;
}


# include <bits/stdc++.h>
using namespace std;
int n, a, cnt, bnt;
int main (){
    cin >> n;
    for (int i = 1; i <= n - 1; i ++){
        cin >> a;
        cnt += a;
    }
    for (int i = 1; i < n; i ++){
        bnt += i;
    }
    cout << bnt - cnt;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
    int n;
    cin>>n;
    int a[n-1];
    for(int i=0;i<n-1;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n-1);
    for(int i=1;i<=n;i++)
    {
        if(a[i]==i){continue;}
        else{cout<<i;break;}
    }
}
int main(){
    solve();
}


#include<bits/stdc++.h>
using namespace std;
long n,q,ans,has[2000000];
int main(){
cin>>n;
for (int i=1;i<n;i++)
{cin>>q;has[q]=1;}
ans=1;
while (has[ans])++ans;
cout<<ans<<endl;
return 0;}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
    int n;
    cin>>n;
    int a[n-1];
    for(int i=0;i<n-1;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=1;i<=n;i++)
    {
        if(a[i]==i){continue;}
        else{cout<<i;break;}
    }
}
int main(){
    solve();
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
    int n;
    cin>>n;
    int a[n-1];
    for(int i=0;i<n-1;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n-1);
    for(int i=1;i<=n-1;i++)
    {
        if(a[i]==i){continue;}
        else{cout<<i;break;}
    }
}
int main(){
    solve();
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <cmath>
#include <string>
#include <iomanip>
#include <math.h>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define ll long long
#define st string
#define fi first
#define se second

const ll N = 1e6 + 10;
const ll INF = 1e18;
const ll inf = -1e18;
const ll MOD = 1e9 + 7;
const ll base = 1000 * 1000 * 1000;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

int main(){
    int n;
    cin >> n;
    vector < int > a(n), b;
    for(int i = 0 ; i < n - 1; ++i)cin >> a[i];
    for(int i = 0; i < n - 1; ++i)b.push_back(i);
    sort(a.begin(), a.end());
    for(int i = 0; i < n - 1; ++i){
        if (a[i] != b[i]){
            cout << i;
            return 0;
        }
    }
    if (a.size() == 2){
        if (a[0] == 1)
            cout << n;
        else cout << 1;
    }else cout << n << "\n";
}


for _ in range(int(input())):
  n=int(input())
  s=input()
  if len(s)<11:
    print("NO")
  elif n>=11 and '8' not in s:
    print("NO")
  elif '8' in s:
    print("YES")


for _ in range(int(input())):
  n=int(input())
  s=input()
  if '8' in s:
    print("YES")
  else:
    print("NO")


for _ in range(int(input())):
  n=int(input())
  s=input()
  if n<11:
    print("NO")
  elif '8' not in s:
    print("NO")
  else:
    print("YES")


for _ in range(int(input())):
  n=int(input())
  s=input()
  s=list(s)
  if '8' in s:
    x=s.index('8')
    if (n-x)>=11:
      print("YES")
    else:
      print("NO")
  else:
    print("NO")


for _ in range(int(input())):
  n=int(input())
  s=input()
  if n>11:
    x=n-11
    if '8' in s[:x]:
      print("YES")
  elif n==11 and s[0]=='8':
    print("YES")
  else:
    print("NO")


for _ in range(int(input())):
  n=int(input())
  s=input()
  s=list(s)
  if '8' in s:
    x=s.index('8')
    if n-x+1>=11: print("YES")
    else:
      print("NO")
  else:
    print("NO")


for _ in range(int(input())):
  n=int(input())
  s=input()
  if n>11:
    x=n-11+1
    if '8' in s[:x]:
      print("YES")
  elif n==11 and s[0]=='8':
    print("YES")
  else:
    print("NO")


T = int(input())
for i in range(T):
    n = int(input())
    s = input()
    if '8' not in s[:n-10]:
        print('NO')
    else:
        print('YES')


T = int(input())
for i in range(T):
    n = int(input())
    print(['NO','YES']['8' in input()[:-10]])


T = int(input())
for i in range(T):
    n = int(input())
    s = input()
    if '8' in s:
        ind = s.index('8')
        #print(len(s[:ind]))
        if n-ind >= 10:
            print('YES')
        else:
            print('NO')
    else:
        print('NO')


T = int(input())
for i in range(T):
    n = int(input())
    s = input()
    ind = s.index('8')
    #print(len(s[:ind]))
    if n-ind >= 10:
        print('YES')
    else:
        print('NO')


T = int(input())
for i in range(T):
    n = int(input())
    s = input()
    if '8' not in s:
        print('NO')
    else:
        print('YES')


T = int(input())
for i in range(T):
    n = int(input())
    s = input()
    if '8' not in s[:n//2+1]:
        print('NO')
    else:
        print('YES')


try:
    def solve():
        n = int(input())
        s = input()
        if n < 11:
            print('NO')
        elif n == 11:
            if s[0] == '8':
                print('YES')
            else:
                print('NO')
        else:
            c = 0
            for j in s:
                c += 1
                if len(s) - c < 10:
                    print('NO')
                    break

                if j == '8' and len(s) -c >= 10:
                    print('YES')
                    break

    t = int(input())
    for _ in range(t):
        solve()
except:
    pass


try:
    def solve():
        n = int(input())
        s = input()
        if n < 11:
            print('NO')
        elif n == 11:
            if s[0] == '8':
                print('YES')
            else:
                print('NO')
        else:
            for j in s:
                if j == '8' and len(s) - 1 - s.index(j) >= 10:
                    print('YES')
                    break
                if len(s) - 1 - s.index(j) <= 10:
                    print('NO')
                    break

    t = int(input())
    for _ in range(t):
        solve()
except:
    pass


try:
    def solve():
        n = int(input())
        s = input()
        if n < 11:
            print('NO')
        elif n == 11:
            if s[0] == '8':
                print('YES')
            else:
                print('NO')
        else:
            c = 0
            for j in s:
                c += 1
                if len(s) - c <= 10:
                    print('NO')
                    break

                if j == '8' and len(s) - 1 - s.index(j) >= 10:
                    print('YES')
                    break

    t = int(input())
    for _ in range(t):
        solve()
except:
    pass


t = int(input())
a = 0
j = 0
for i in range(t):
    k = int(input())
    l = list(input())
    while True:
        if l[j] == "8":
            a = j
            if k - a >= 10:
                print("YES")
                break
            else:
                print("NO")
                break
        j += 1
    print("NO")


t = int(input())
a = 0
for i in range(t):
    k = int(input())
    l = list(input())
    for j in range(k):
        if l[j] == "8":
            a = j
            if abs(k - a) >= 10:
                print("YES")
            else:
                print("NO")


n = int(input())
k = int(input())
for i in range(n):
    j = str(input())
    if j[1] == "8" and len(j) == k + 1:
        print("YES")
    elif j[0] == "8" and len(j) == k + 1:
        print("YES")
    elif j[0] == "8" and len(j) == k:
        print("YES")
    else:
        print("NO")


t = int(input())
for i in range(t):
    k = int(input())
    l = list(input())
    for j in range(k):
        if l[j] == "8":
            if k - j >= 11:
                print("YES")
            else:
                print("NO")


n = int(input())
k = int(input())
for i in range(n):
    j = str(input()))
    if j[1] == "8" and len(j) == k + 1:
        print("YES")
    elif j[0] == "8" and len(j) == k + 1:
        print("YES")
    elif j[0] == "8" and len(j) == k:
        print("YES")
    else:
        print("NO")


y = int(input())
for i in range(y):
    n = int(input())
    s = input()
    if(s[0] == "8") and (len(s) == 11):
        print("YES")
    else:
        c = 0
        for j in range(len(s)):
            if(s[j] == "8"):
                break
            else:
                c += 1
        if(len(s) - c) >= 11:
            print("YES")
        else:
            print("NO")


t = int(input())
a = 0
j = 0
for i in range(t):
    k = int(input())
    l = list(input())
    while j < len(l):
        if l[j] == "8":
            a = j
            if k - a >= 10:
                print("YES")
                break
        j += 1
    if "8" not in l:
        print("NO")


n = int(input())
k = []
m = []
for i in range(n):
    l = int(input())
    s = input()
    k.append(s)
    m.append(l)

for p in range(n):
    count = 0

    for q in range(len(k[p])):
        count += 1

        if int(k[p][q]) == 8:
            print('YES')
            break

        if count > (len(k[p]) - 11):
            print('NO')
            break


n = int(input())
k = []
m = []
for i in range(n):
    l = int(input())
    s = input()
    k.append(s)
    m.append(l)

for p in range(n):
    count = 0

    if int(m[p]) < 11:
        print('NO')
        break

    for q in range(len(k[p])):
        count += 1

        if int(k[p][q]) == 8:
            print('YES')
            break

        if count > (int(m[p]) - 11):
            print('NO')
            break


n = int(input())
k = []
m = []
for i in range(n):
    l = int(input())
    s = input()
    k.append(s)
    m.append(l)

for p in range(n):
    count = 0

    for q in range(len(k[p])):
        count += 1

        if int(k[p][q]) == 8:
            print('YES')
            break

        if int(m[p]) < 11:
            print('NO')
            break

        if count > (int(m[p]) - 11):
            print('NO')
            break


n = int(input())
k = []
m = []
for i in range(n):
    l = int(input())
    s = input()
    k.append(s)
    m.append(l)

for p in range(n):
    count = 0

    for q in range(len(k[p])):
        count += 1

        if int(k[p][q]) == 8:
            print('YES')
            break

        if count > (int(m[p]) - 11):
            print('NO')
            break


n = int(input())
k = []
m = []
for i in range(n):
    l = int(input())
    s = input()
    k.append(s)
    m.append(l)

for p in range(n):
    count = 0

    if int(m[p]) < 11:
        print('NO')
        break

    for q in range(len(k[p])):
        count += 1

        if int(k[p][q]) == 8:
            print('YES')
            break

        if int(m[p]) < 11:
            print('NO')
            break

        if count > (int(m[p]) - 11):
            print('NO')
            break


n = int(input())
k = []
m = []
for i in range(n):
    l = int(input())
    s = input()
    k.append(s)
    m.append(l)

for p in range(n):
    count = 0

    for q in range(len(k[p])):
        count += 1

        if int(m[p]) < 11:
            print('NO')
            break

        if int(k[p][q]) == 8:
            print('YES')
            break

        if count > (int(m[p]) - 11):
            print('NO')
            break


n = int(input())
k = []
m = []
for i in range(n):
    l = int(input())
    s = input()
    k.append(s)
    m.append(l)

for p in range(n):
    count = 0

    for q in range(len(k[p])):
        count += 1

        if int(k[p][q]) == 8:
            print('YES')
            break

        n = int(input())
k = []
m = []
for i in range(n):
    l = int(input())
    s = input()
    k.append(s)
    m.append(l)

for p in range(n):
    count = 0

    for q in range(len(k[p])):
        count += 1

        if int(k[p][q]) == 8:
            print('YES')
            break

        if int(m[p]) < 11:
            print('NO')
            break

        if count > (int(m[p]) - 11):
            print('NO')
            break


t=int(input())
for _ in range(t):
    n=int(input())
    x=input()
    i=0
    while(n>=11):
        if x[i]==8:
            print("YES")
            break
        i=i+1
        n=n-1
    if n<11:
        print("NO")


t=int(input())
for _ in range(t):
    x=int(input())
    n=input()
    i=0
    while(x>=11):
        print(n[i])
        if n[i]=="8":
            print("YES")
            break
        i=i+1
        x=x-1
    if x<11:
        print("NO")


t=int(input())
for _ in range(t):
    x=int(input())
    n=input()
    i=0
    while(x>=11):
        if n[i]=="8":
            print("YES")
            break
        i=i+1
        x=x-1
    if x<11:
        print("NO")


n=input()
x=len(n)
i=0
while(x>=11):
    if n[i]==8:
        print("YES")
    i=i+1
    x=x-1
if x<11:
    print("NO")


t=int(input())
for _ in range(t):
    n=input()
    x=len(n)
    i=0
    while(x>=11):
        if n[i]==8:
            print("YES")
        i=i+1
        x=x-1
    if x<11:
        print("NO")


t=int(input())
for _ in range(t):
    n=input()
    x=len(n)
    i=0
    while(x>=11):
        if n[i]==8:
            print("YES")
            break
        i=i+1
        x=x-1
    if x<11:
        print("NO")


x = int(input())
y = []
for c in range(x):
    t = []
    t.append(int(input()))
    t.append(input())
    y.append(t)
no = 0
for c in y:
    if c[0] - 11 == 0:
        if c[1][0] == "8":
            print("YES")
            break
        if c[1][0] != "8":
            print("NO")
            break
    elif c[0] < 11:
        print("NO")
        break
    else:
        for cc in range(1,c[0]-11+1):
            if c[1][cc] == "8":
                print("YES")
                no = no +1
                break
            if no == c[0]-11:
                print("NO")
                break


x = int(input())
y = []
for c in range(x):
    t = []
    t.append(int(input()))
    t.append(input())
    y.append(t)
no = 0

for c in y:
    if c[0] - 11 == 0:
        if c[1][0] == "8":
            print("YES")
        if c[1][0] != "8":
            print("NO")
        continue
    elif c[0] < 11:
        print("NO")
        break
        continue
    else:
        for cc in range(1,c[0]-11+1):
            if c[1][cc] == "8":
                print("YES")
                continue
            else:
                no = no +1

            if no == c[0]-11:
                print("NO")


x = int(input())
y = []
for c in range(x):
    t = []
    t.append(int(input()))
    t.append(input())
    y.append(t)

for c in y:
    no = 0
    count = 0
    if c[0] - 11 == 0:
        if c[1][0] == "8":
            print("YES")
        if c[1][0] != "8":
            print("NO")
        continue
    elif c[0] < 11:
        print("NO")
        continue
    else:
        for cc in c[1]:
            if cc == "8":
                no = no+1
                count = count +1
            else:
                count = count +1
            if count > len(c[1])-11:
                break

    if no > 0:
        print("YES")
    else:
        print("NO")


x = int(input())
y = []
for c in range(x):
    t = []
    t.append(int(input()))
    t.append(input())
    y.append(t)
no = 0

for c in y:
    if c[0] - 11 == 0:
        if c[1][0] == "8":
            print("YES")
        if c[1][0] != "8":
            print("NO")
        continue
    elif c[0] < 11:
        print("NO")
        break
        continue
    else:
        for cc in range(1,c[0]-11+1):
            if c[1][cc] == "8":
                print("YES")
                break
            else:
                no = no +1

            if no == c[0]-11:
                print("NO")


x = int(input())
y = []
for c in range(x):
    t = []
    t.append(int(input()))
    t.append(input())
    y.append(t)
no = 0

for c in y:
    if c[0] - 11 == 0:
        if c[1][0] == "8":
            print("YES")
        if c[1][0] != "8":
            print("NO")
        continue
    elif c[0] < 11:
        print("NO")
        break
        continue
    else:
        for cc in range(1,c[0]-11+1):
            if c[1][cc] == "8":
                print("YES")
                break
            else:
                no = no +1

    if no == c[0]-11:
        print("NO")
    no = 0


x = int(input())
y = []
for c in range(x):
    t = []
    t.append(int(input()))
    t.append(input())
    y.append(t)
no = 0

for c in y:
    if c[0] - 11 == 0:
        if c[1][0] == "8":
            print("YES")
        if c[1][0] != "8":
            print("NO")
        continue
    elif c[0] < 11:
        print("NO")
        continue
    else:
        for cc in range(c[0]-11):
            if c[1][cc] == "8":
                print("YES")
                break
            else:
                no = no +1

    if no == c[0]-11:
        print("NO")
    no = 0


x = int(input())
y = []
for c in range(x):
    t = []
    t.append(int(input()))
    t.append(input())
    y.append(t)
no = 0

for c in y:
    if c[0] - 11 == 0:
        if c[1][0] == "8":
            print("YES")
        if c[1][0] != "8":
            print("NO")
        continue
    elif c[0] < 11:
        print("NO")
        continue
    else:
        for cc in range(1,c[0]-11+1):
            if c[1][cc] == "8":
                print("YES")
                break
            else:
                no = no +1

    if no == c[0]-11:
        print("NO")
    no = 0


x = int(input())
y = []
for c in range(x):
    t = []
    t.append(int(input()))
    t.append(input())
    y.append(t)
no = 0

for c in y:
    if c[0] - 11 == 0:
        if c[1][0] == "8":
            print("YES")
        if c[1][0] != "8":
            print("NO")
        continue
    elif c[0] < 11:
        print("NO")
        break
        continue
    else:
        for cc in range(1,c[0]-11+1):
            if c[1][cc] == "8":
                print("YES")
                break
            else:
                no = no +1

    if no == c[0]-11:
        print("NO")


x = int(input())
y = []
for c in range(x):
    t = []
    t.append(int(input()))
    t.append(input())
    y.append(t)
no = 0

for c in y:
    if c[0] - 11 == 0:
        if c[1][0] == "8":
            print("YES")
        if c[1][0] != "8":
            print("NO")
        continue
    elif c[0] < 11:
        print("NO")
        continue
    else:
        for ccc in range(c[0]-11):
            if ccc > len(c[1])-1:
                break
            elif c[1][ccc] == "8":
                print("YES")
                break
            else:
                no = no +1

    if no == c[0]-11:
        print("NO")
    no = 0


x = int(input())
y = []
for c in range(x):
    t = []
    t.append(int(input()))
    t.append(input())
    y.append(t)
no = 0

for c in y:
    if c[0] - 11 == 0:
        if c[1][0] == "8":
            print("YES")
        if c[1][0] != "8":
            print("NO")
        continue
    elif c[0] < 11:
        print("NO")
        continue
    else:
        for cc in c[1][:-11]:
            if cc == "8":
                no = no+1

    if no > 0:
        print("YES")
    else:
        print("NO")
    no = 0


x = int(input())
y = []
for c in range(x):
    t = []
    t.append(int(input()))
    t.append(input())
    y.append(t)
no = 0
for c in y:
    if c[0] - 11 == 0:
        if c[1][0] == "8":
            print("YES")
        if c[1][0] != "8":
            print("NO")
    elif c[0] < 11:
        print("NO")
    else:
        for cc in range(1,c[0]-11+1):
            if c[1][cc] == "8":
                print("YES")
                no = no +1
            if no == c[0]-11:
                print("NO")


x = int(input())
y = []
for c in range(x):
    t = []
    t.append(int(input()))
    t.append(input())
    y.append(t)
no = 0
for c in y:
    if c[0] - 11 == 0:
        if c[1][0] == "8":
            print("YES")
        if c[1][0] != "8":
            print("NO")
        continue
    elif c[0] < 11:
        print("NO")
        break
        continue
    else:
        for cc in range(1,c[0]-11+1):
            if c[1][cc] == "8":
                print("YES")
                no = no +1

            if no == c[0]-11:
                print("NO")


t = int(input())
for i in range(t):
    ret = []
    n = int(input())
    s = input()
    for j in range(n):
        if s[j] == '8':
            if n >= j + 10:
                ret.append('YES')
        else:
            ret.append('NO')
    if 'YES' in ret:
        print('YES')
    else:
        print('NO')


t = int(input())
integer = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
for j in range(t):
    n = int(input())
    s = input()
    for i in range(len(s) - 1):
        if s[i] == '8' and s[i + 7] in integer:
            print('YES')
            break
        s = s + '8'
        if '8' not in integer or len(s) < 8 or (len(s) - int(s.index('8'))) < 8:
            print('NO')
            break


t = int(input())
for j in range(t):
    n = int(input())
    s = input()
    if len(s) == n:
        for i in range(len(s) - 1):
            if s.find('8') == -1:
                print('NO')
                break
            elif len(s) < 8:
                print('NO')
                break
            else:
                if (len(s) - int(s.find('8')) >= 8):
                    print('YES')
                elif (len(s) - int(s.find('8'))) < 8:
                    print('NO')
                break


t = int(input())
for j in range(t):
    n = int(input())
    s = input()
    if n > 11:
        if s.find('8') == -1:
            print('NO')
        else:
            if (len(s) - int(s.find('8')) >= 11):
                print('YES')
            elif (len(s) - int(s.find('8'))) < 11:
                print('NO')
    else:
        print('NO')


t = int(input())
for j in range(t):
    n = int(input())
    s = input()
    for i in range(len(s) - 1):
        if s.find('8') == -1:
            print('NO')
            break
        elif len(s) < 11:
            print('NO')
            break
        else:
            if (len(s) - int(s.find('8')) >= 11):
                print('YES')
            elif (len(s) - int(s.find('8'))) < 11:
                print('NO')
            break


t = int(input())
integer = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
for j in range(t):
    n = int(input())
    s = input()
    for i in range(len(s) - 1):
        if s.find('8') == -1:
            print('NO')
            break
        elif len(s) < 8:
            print('NO')
            break
        else:
            if (len(s) - int(s.find('8')) >= 8):
                print('YES')
            elif (len(s) - int(s.find('8'))) < 8:
                print('NO')
            break


t = int(input())
integer = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
for j in range(t):
    n = int(input())
    s = input()
    if len(s) == n:
        for i in range(len(s) - 1):
            if s.find('8') == -1:
                print('NO')
                break
            elif len(s) < 8:
                print('NO')
                break
            else:
                if (len(s) - int(s.find('8')) >= 8):
                    print('YES')
                elif (len(s) - int(s.find('8'))) < 8:
                    print('NO')
                break


t = int(input())
integer = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
for j in range(t):
    n = int(input())
    s = input()
    s = s + '8'
    for i in range(len(s) - 1):
        if s[i] == '8' and s[i + 7] in integer:
            print('YES')
            break
        elif '8' not in integer or len(s) < 8 or (len(s) - int(s.index('8'))) < 8:
            print('NO')
            break


t = int(input())
for i in range(t):
    n = int(input())
    s = input()
    if n < 11 or '8' not in s:
        print('NO')
    else:
        ret = 0
        for j in range(n):
            if s[j] == '8' and n - j >= 11:
                ret = 1
        if ret == 1:
            print('YES')
        else:
            print('NO')


t = int(input())
integer = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
for j in range(t):
    n = int(input())
    s = input()
    for i in range(len(s) - 1):
        if s.find('8') == -1 or len(s) < 8:
            print('NO')
            break
        else:
            if (len(s) - int(s.find('8')) >= 8):
                print('YES')
            break


for _ in range(int(input())):
    n = int(input())
    l = input()
    print('YES' if((('8' in l[:(n-11)]) and n>=11) or (n==11 and l[0]=='8')) else 'NO')


for _ in range(int(input())):
    n = int(input())
    print('YES' if('8' in input()[:(n-11)]) else 'NO')


for _ in range(int(input())):
    n = int(input())
    l = input()
    print('YES' if((('8' in l[:(n-11+1)]) and n>=11) or (n==11 and l[0]=='8')) else 'NO')


res = []
for i in range(int(input())):
    size = int(input())
    res.append("YES" if str(input())[:size-10].count('8') > 0 else "NO")

print('\n'.join(res))


res = []
for i in range(int(input())):
    size = int(input())
    res.append("YES" if str(input())[:size-11].count('8') > 0 else "NO")

print('\n'.join(res))


res = []
for i in range(int(input())):
    size = int(input())
    res.append("YES" if '8' in str(input())[:-10] else "NO")

print('\n'.join(res))


res = []
for i in range(int(input())):
    size = int(input())
    res.append("YES" if (size > 10 and '8' in str(input())[:size-10]) else "NO")

print('\n'.join(res))


t = int(input())
posicion=0
for i in range(t):
	n = int(input())
	numeros = input()
	if(n<11 or (n==11 and numeros[0]!=8)):
		print("NO")
	else:
		for j in range(n):
			if(numeros[j]=="8"):
				if(n-j>=11):
					print("YES")
				break


t = int(input())
hay8=0
for i in range(t):
	n = int(input())
	numeros = input()
	if(n<11 or (n==11 and numeros[0]!="8")):
		print("NO")
	elif(n==11 and numeros[0]=="8"):
		print("YES")
	else:
		for j in range(n):
			if(numeros[j]=="8"):
				hay8=1
				if(n-j>=11):
					print("YES")
				break
		if(hay8==0):
			print("NO")


t = int(input())
hay8=0
for i in range(t):
	hay8=0
	n = int(input())
	numeros = input()
	if(n<11 or (n==11 and numeros[0]!="8")):
		print("NO")
	elif(n==11 and numeros[0]=="8"):
		print("YES")
	else:
		for j in range(n):
			if(numeros[j]=="8"):
				hay8=1
				if(n-j>=11):
					print("YES")
				else:
					print("NO")
				break
		if(hay8==0):
			print("NO")


t = int(input())
hay8=0
for i in range(t):
	n = int(input())
	numeros = input()
	if(n<11 or (n==11 and numeros[0]!="8")):
		print("NO")
	elif(n==11 and numeros[0]=="8"):
		print("YES")
	else:
		for j in range(n):
			if(numeros[j]=="8"):
				hay8=1
				if(n-j>=11):
					print("YES")
				else:
					print("NO")
				break
		if(hay8==0):
			print("NO")


t = int(input())
for i in range(t):
	n = int(input())
	numeros = input()
	if(n<11 or (n==11 and numeros[0]!="8")):
		print("NO")
	elif(n==11 and numeros[0]=="8"):
		print("YES")
	else:
		for j in range(n):
			if(numeros[j]=="8"):
				if(n-j>=11):
					print("YES")
				break


t = int(input())

for _ in range(t):
	n = int(input())
	s = input()

	if s.startswith('8') and len(s) >=11:
		print('YES')

	elif len(s[s.index('8'):]) >= 11:
		print('YES')

	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()

	if not s:
		print('NO')

	if len(s) < 11:
		print('NO')

	if '8' not in s:
		print('NO')

	elif s.startswith('8'):
		if len(s[:12]) == 11:
			print('YES')

		else:
			print('NO')

	else:
		for i in s:
			if i == '8':
				if len(s[s.index(i):12]) == 11:
					print('YES')
				else:
					print('NO')


t = int(input())

for _ in range(t):
	n = int(input())
	s = input()

	if s.startswith('8') and len(s) >=11:
		print('YES')

	elif '8' not in s:
		print('NO')

	elif len(s[s.index('8'):]) >= 11:
		print('YES')

	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()

	if not s:
		print('NO')
		break

	if len(s) < 11:
		print('NO')
		break

	if '8' not in s:
		print('NO')
		break

	elif s.startswith('8'):
		if len(s[:12]) == 11:
			print('YES')
			break

		else:
			print('NO')
			break

	else:
		for i in s:
			if i == '8':
				if len(s[s.index(i):12]) == 11:
					print('YES')
					break
				else:
					print('NO')
					break


t = int(input())

for _ in range(t):
	n = int(input())
	s = input()

	if '8' in s[-10:]:
		print('YES')

	else:
		print('NO')


t = int(input())

for _ in range(t):
	n = int(input())
	s = input()

	if '8' in s[:-10]:
		print('YES')

	else:
		print('NO')


t = int(input())

for _ in range(t):
	n = int(input())
	s = input()

	if not s:
		print('NO')
		break

	if len(s) < 11:
		print('NO')
		break

	if '8' not in s:
		print('NO')
		break

	elif s.startswith('8'):
		if len(s[:12]) == 11:
			print('YES')
			break

		else:
			print('NO')
			break

	else:
		for i in s:
			if i == '8':
				if len(s[s.index(i):12]) == 11:
					print('YES')
					break
				else:
					print('NO')
					break


t = int(input())

for _ in range(t):
	n = int(input())
	s = input()

	if not s:
		print('NO')

	if len(s) < 11:
		print('NO')

	if '8' not in s:
		print('NO')

	elif s.startswith('8'):
		if len(s[:12]) == 11:
			print('YES')

		else:
			print('NO')

	else:
		for i in s:
			if i == '8':
				if len(s[s.index(i):12]) == 11:
					print('YES')

				else:
					print('NO')


t = int(input())

for _ in range(t):
	n = int(input())
	s = input()

	if not s:
		print('NO')

	if len(s) < 11:
		print('NO')

	if '8' not in s:
		print('NO')

	elif s.startswith('8'):
		if len(s[:12]) == 11:
			print('YES')

		else:
			print('NO')

	else:
		for i in s:
			if i == '8':
				if len(s[s.index(i):12]) == 11:
					print('YES')
					break

				else:
					print('NO')


t = int(input())
result = []

for test_case in range(t):
    n = int(input())
    string = input()

    if n < 11:
        result.append("NO")
    elif n == 11:
        if string[0] == "8":
            result.append("YES")
        else:
            result.append("NO")
    else:
        if "8" in string[:n - 11]:
            result.append("YES")
        else:
            result.append("NO")

for i in result:
    print(i)


t = int(input())
result = []

for test_case in range(t):
    n = int(input())
    string = input()

    if n < 11:
        result.append("NO")
    else:
        if "8" in string[:n - 10]:
            result.append("YES")
        else:
            result.append("NO")

for i in result:
    print(i)


t = int(input())
result = []

for test_case in range(t):
    n = int(input())
    string = input()

    if n < 11:
        result.append("NO")
    else:
        if "8" in string[:n - 11]:
            result.append("YES")
        else:
            result.append("NO")

for i in result:
    print(i)


t = int(input())
result = []

for test_case in range(t):
    n = int(input())
    string = input()

    if n < 11:
        result.append("NO")
    else:
        if string[n - 12] == "8":
            result.append("YES")
        else:
            result.append("NO")

for i in result:
    print(i)


t = int(input())    # 1 <= t <= 100

for i in range(t):
    n = int(input())
    s = input()

    if "8" not in s or n < 11:
        print("NO")
    else:
        print("YES")


def is_valid_telephone(s):
    if len(s) < 11 or "8" not in s:
        return False

    if s[0] == "8" and len(s) > 11:
        return True

    return is_valid_telephone(s[i+1:])

t = int(input())    # 1 <= t <= 100

for i in range(t):
    n = int(input())
    s = input()

    if is_valid_telephone(s):
        print("YES")
    else:
        print("NO")


def is_valid_telephone(s, n):
    if n < 11 or "8" not in s:
        return False

    if s[0] == "8" and n >= 11:
        return True

    return is_valid_telephone(s[i+1:], n-1)

t = int(input())    # 1 <= t <= 100

for i in range(t):
    n = int(input())
    s = input()

    if is_valid_telephone(s, n):
        print("YES")
    else:
        print("NO")


def is_telephone(n, s):
    for c in s:
        if c == '8' and n >= 11: return True
        n -= 1
    return False

def main():
    t = int(input())
    for i in range(t):
        n = int(input())
        s = input()

        if is_telephone(n, s):
            print('YES')
        else:
            print('NO')

main()


t = int(input())
for i in range(t):
    n = int(input())
    s = input()
    idx = -1
    for i in range(n):
        if s[i] == '8':
            idx = i
            break
    if idx == -1:
        print("NO")
    elif n - idx >= 10:
        print("YES")
    else:
        print("NO")


t = int(input())
for i in range(t):
    n = int(input())
    s = input()
    try:
        if n - s.index('8') >= 10:
            print("YES")
        else:
            print("NO")
    except:
        print("NO")


t = int(input())
for i in range(t):
    n = int(input())
    s = input()
    idx = -1
    for i in range(n):
        if s[i] == '8':
            idx = i
            break
    if idx == -1:
        print("NO")
    elif n - idx >= 11:
        print("YES")
    else:
        print("NO")


t = int(input())
for i in range(t):
    n = int(input())
    s = input()
    idx = -1
    for i in range(n):
        if s[i] == 8:
            idx = i
            break
    if idx == -1:
        print("NO")
    elif n - idx >= 10:
        print("YES")


t = int(input())
for i in range(t):
    n = int(input())
    s = input()
    try:
        if n - s.index('8') >= 10:
            print("YES")
    except:
        print("NO")


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	index = -1
	flag = 0
	for i in range(len(s)):
		if s[i] == '8':
			flag = 1
			index = i
			break
	if flag == 1:
		if (n - index) >= 11:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()

	if s[0] == '8' and len(s)==11:
		print('YES')
	else:
		l = len(s)
		for i in range(len(s)):
			# print('y')
			if s[i] == '8':
				s = s[i:]
				# print(s)
				break
		if s[0] == '8':
			if len(s) >= 11:
				print('YES')

		else:
			print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()

	if s[0] == '8' and len(s)==11:
		print('YES')
	else:
		l = len(s)
		for i in range(len(s)):
			# print('y')
			if s[i] == '8':
				s = s[i:]
				print(s)
				break
		if s[0] == '8':
			if len(s) >= 11:
				print('YES')

		else:
			print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()

	if s[0] == '8' and len(s)==11:
		print('YES')
	else:
		l = len(s)
		for i in range(len(s)):
			# print('y')
			if s[i] == '8':
				s = s[i:]
				# print(s)
				break
		if s[0] == '8':
			if len(s) >= 11:
				print('YES')

		if s[0]!='8':
			print('NO')


def a(b):
    if len(b)-b.find('8') >= 11 and len(b) != -1:
        print('YES')
    else:
        print('NO')
for i in range(int(input())):
    d=input()
    a(input())


def a(b):
    if len(b)-b.find('8') >= 11 and b.find('8') != -1:
        print('YES')
    else:
        print('NO')
for i in range(int(input())):
    d=input()
    a(input())


def a(b):
    if len(b)-b.find('8') <= 11:
        print('YES')
    else:
        print('NO')
for i in range(int(input())):
    a(input())


#include <bits/stdc++.h>
#define fi first
#define se second
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define lowbit(x) x&-x
#define pb push_back
#define MP make_pair
#define clr(a) memset(a,0,sizeof(a))
#define _INF(a) memset(a,0x3f,sizeof(a))
#define FIN freopen("in.txt","r",stdin)
#define fuck(x) cout<<"["<<x<<"]"<<endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>pii;
//head
const int MX=1500+7;

int n,m;
int a[MX];
struct node{
	int l,r;
}b[MX];

int main(){
	scanf("%d",&n);
	int t=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		t+=a[i];
	}
	int ans=1e9;
	scanf("%d",&m);
	int ok=0;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&b[i].l,&b[i].r);
		if(b[i].r>=t){
			ans=min(ans,max(b[i].l,t));
			ok=1;
		}
	}
	if(!ok)
		puts("-1");
	else
		printf("%d\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const long long M = 1e8 ;
int main()
{
    ll n,m,sum=0,i,x,y,k=0,p=0,ans;
    cin>>n;
    vector< ll >ara;
    vector< pair< ll,ll >>vec;
    for(i=0;i<n;i++){
        cin>>x;
        sum+=x;
    }
    cin>>m;
    for(i=0;i<m;i++){
        cin>>x>>y;
        vec.pb({x,y});
    }
        for(i=0;i<m;i++){
            if(sum>=vec[i].first && sum<=vec[i].second){
                k=1;
                break;
            }
    }

    if(k)
        cout<<sum<<"\n";
    else{
        for(i=0;i<m;i++){
            if(sum<vec[i].first){
                    ans=vec[i].first;
                    p=1;
                break;
            }
            }
    if(p)
        cout<<ans<<"\n";
    else
           cout<<"-1"<<"\n";

    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const long long M = 1e8 ;
int main()
{
    ll n,m,sum=0,p,i,x,y,f=1;
    cin>>n;
    vector< ll >ara;
    vector< pair< ll,ll >>vec;
    for(i=0;i<n;i++){
        cin>>x;
        ara.pb(x);
    }
    cin>>m;
    for(i=0;i<m;i++){
        cin>>x>>y;
        vec.pb({x,y});
    }
    for(i=0;i<n;i++){
        p=sum+ara[i];
        if(p>=vec[i].first && p<=vec[i].second){
            sum+=ara[i];
        }
        else{
            f=0;
            break;
        }
    }
    if(f)
        cout<<sum<<"\n";
    else
        cout<<"-1"<<"\n";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const long long M = 1e8 ;
int main()
{
    ll n,m,sum=0,i,x,y,k=0,p=0,ans;
    cin>>n;
    vector< ll >ara;
    vector< pair< ll,ll >>vec;
    for(i=0;i<n;i++){
        cin>>x;
        sum+=x;
    }
    cin>>m;
    for(i=0;i<m;i++){
        cin>>x>>y;
        vec.pb({x,y});
    }
        for(i=0;i<m;i++){
            if(sum>=vec[i].first && sum<=vec[i].second){
                k=1;
                break;
            }
    }

    if(k)
        cout<<sum<<"\n";
    else{
        for(i=0;i<m;i++){
            if(sum<vec[i].first){
                    ll ans=vec[i].first;
                    p=1;
                break;
            }
            }
    if(p)
        cout<<ans<<"\n";
    else
           cout<<"-1"<<"\n";

    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const long long M = 1e8 ;
int main()
{
    ll n,m,sum=0,p,i,x,y,k=0,add=0;
    cin>>n;
    vector< ll >ara;
    vector < ll > nw;
    vector< pair< ll,ll >>vec;
    for(i=0;i<n;i++){
        cin>>x;
        ara.pb(x);
    }
    sort(ara.begin(),ara.end());
    for(i=0;i<n;i++){
        add=add+ara[i];
        nw.pb(add);
    }
    p=nw[n-1];
    cin>>m;
    for(i=0;i<m;i++){
        cin>>x>>y;
        vec.pb({x,y});
    }
    //for(auto it:nw) cout<<it<<" ";
    //cout<<endl;
    for(i=0;i<n;i++){
        for(ll j=k;j<m;j++){
            if(nw[i]>=vec[j].first && nw[i]<vec[j].second){
                k=j;
                nw[i]=0;
                break;
            }
            else if(nw[i]>=vec[j].first && nw[i]<=vec[j].second){
                k=j+1;
                nw[i]=0;
                break;
            }
        }
     // cout<<nw[i]<<" ";
    }
    if(nw[n-1]==0)
        cout<<p<<"\n";
    else
        cout<<"-1"<<"\n";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const long long M = 1e8 ;
int main()
{
    ll n,m,sum=0,i,x,y,k=0;
    cin>>n;
    vector< ll >ara;
    vector< pair< ll,ll >>vec;
    for(i=0;i<n;i++){
        cin>>x;
        sum+=x;
    }
    cin>>m;
    for(i=0;i<m;i++){
        cin>>x>>y;
        vec.pb({x,y});
    }
        for(i=0;i<m;i++){
            if(sum>=vec[i].first && sum<=vec[i].second){
                k=1;
                break;
            }
    }
    if(k)
        cout<<sum<<"\n";
    else
        cout<<"-1"<<"\n";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const long long M = 1e8 ;
int main()
{
    ll n,m,sum=0,p,i,x,y,k=0,add=0;
    cin>>n;
    vector< ll >ara;
    vector < ll > nw;
    vector< pair< ll,ll >>vec;
    for(i=0;i<n;i++){
        cin>>x;
        ara.pb(x);
    }
    sort(ara.begin(),ara.end());
    for(i=0;i<n;i++){
        add=add+ara[i];
        nw.pb(add);
    }
    p=nw[n-1];
    cin>>m;
    for(i=0;i<m;i++){
        cin>>x>>y;
        vec.pb({x,y});
    }
    for(i=0;i<n;i++){
        for(ll j=k;j<m;j++){
            if(nw[i]>=vec[j].first && nw[i]<=vec[j].second){
                k=j+1;
                nw[i]=0;
                break;
            }
        }

    }
    if(nw[n-1]==0)
        cout<<p<<"\n";
    else
        cout<<"-1"<<"\n";

    return 0;
}