#include <iostream>
#include <stdlib.h>
using namespace std;

int find(long k,long* A,int n);

int main(void){
  int n;
  cin>>n;
  long A[n];
  for(long i=0;i<n;i++){
    cin>>A[i];
  }

  int m;
  cin>>m;
  long k;
  int retval=0;
  for(int i=0;i<m;i++){
    cin>>k;
    retval+=find(k,A,n);
  }
  if(retval==m){
    cout<<1<<endl;
  }
  else{
    cout<<0<<endl;
  }
}

int find(long k, long* A,int n){
  long low = 0;
  long high = n-1;
  long mid;
  while (high-low>10){
    mid = (high+low)/2;
    if(A[mid]>k){
      high=mid;
    }
    else{
      low=mid;
    }
  }

  for(long i=low;i<=high;i++){
    if(A[i]==k){
      return 1;
    }
  }
  return 0;
}

