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

signed main (){
	int n, m, i, j = 0;
	bool f;
	
	cin >> n;
	int a[n];
	for (i = 0; i < n; i++) cin >> a[i];
	cin >> m;
	int b[m];
	for (i = 0; i < m; i++) cin >> b[i];
	i = 0;
	while(i < m){
		if (a[j] < b[i]){
			j++;
			f = 0;
		}
		else if (a[j] == b[i]){
			i++;
			j++;
			f = 1;
		}
		else {
			f = 0;
			break;
		}
	}
	cout << f << endl;
	return 0;
}

