import java.util.Scanner;
import java.util.Iterator;
import java.util.LinkedList;
public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        LinkedList<Integer> list = new LinkedList();
        int n = sc.nextInt();    // 数据个数n
        for(int i = 0 ; i < n ; i++) {
            list.add(sc.nextInt());
        }
        int m = sc.nextInt();    // 输入欲删除数据m
        Iterator<Integer> iterator = list.iterator();
        while(iterator.hasNext()) {
            if(iterator.next() == m) {
                iterator.remove();
            }
        }
        System.out.println(list.size());
        for(Integer integer : list) {
            if(integer != m) {
                System.out.print(integer + " ");
            }
        }
    }
}