#include <cstdio>
#include <cstdlib>
using namespace std;

const char fin[] = "lant.in", fout[] = "lant.out", fok[] = "lant.ok";
long long a[1001], anin;
int nrout, nrok;

void result(const char msg[], const int p) {
    fprintf(stderr, msg);
    printf("%d", p);
    exit(0);
}

bool check(){
    bool ok1 = 1;
    for(int k = 1; k < nrout && ok1; k++){
        bool ok2 = 0;
        for(int i = 0; i < nrout && !ok2; i++)
            for(int j = 0; j < nrout && !ok2; j++)
                ok2 = (a[i] + a[j] == a[k]);
        ok1 &= ok2;
    }
    return (ok1 && (nrout <= 150) && (a[nrout - 1] == anin) && (a[0] == 1));
}

int main(){
    FILE *in = fopen(fin, "r"), *out = fopen(fout, "r"), *ok = fopen(fok, "r");
    ///IN
    if (!in) result("Fisier de intrare lipsa!", 0);
    if (fscanf(in, "%lld", &anin) != 1)
        result("Fisier de intrare corupt!", 0);
    if (anin < 2 || anin > 1000000000000)
        result("Fisier de intrare corupt!", 0);
    ///OUT
    if (!out) result("Fisier de iesire lipsa!", 0);
    if (fscanf(out, "%d", &nrout) != 1)
        result("Fisier de iesire corupt!", 0);
    for(int i = 0; i < nrout; i++)
        if (fscanf(out, "%lld", &a[i]) != 1)
            result("Fisier de iesire corupt!", 0);
    ///OK
    if (!ok) result("Fisier ok lipsa!", 0);
    if (fscanf(ok, "%d", &nrok) != 1)
        result("Fisier ok corupt!", 0);
    ///EVAL
    if (check()) result("Raspuns corect!", 10);
    else result("Raspuns gresit!", 0);

    ///END
    fclose(in), fclose(out), fclose(ok);
    return 0;
}
