"use strict";
function Main(input) {
    let lines = input.split("\n");
    let nums = lines.shift().split(/\s/).map((v) => v - 0);
    let N = nums[0];
    let A = nums[1];
    let B = nums[2];
    let C = nums[3];
    let Tn = []
    for (let n = 1; n <= N; n++) {
        Tn.push(lines.shift() - 0);
    }
    Tn.sort(function(a, b) { return b - a; });
    let mpA = 0, mpB = 0, mpC = 0;
    let fA = false, fB = false, fC = false;
    Tn.forEach((v, i, array) => {
        if (v == A) { array[i] = 0; fA = true}
    });
    Tn.forEach((v, i, array) => {
        if (v == B) { array[i] = 0; fB = true}
    });
    Tn.forEach((v, i, array) => {
        if (v == C) { array[i] = 0; fC = true}
    });
    

    console.log((fA && fB && fC ) ? 0 : -1);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
