//
// soda.cpp
// algorithm
//
// Created by david.xu on 2019/9/15.
// Copyright 漏 2019骞?david.xu. All rights reserved.
//
include [HTML_REMOVED]
include [HTML_REMOVED]
include [HTML_REMOVED]
include [HTML_REMOVED]
include [HTML_REMOVED]
include [HTML_REMOVED]
include [HTML_REMOVED]
include [HTML_REMOVED]
using namespace std;
int n,m,k;
int d[2010];
int s[2010];
queue [HTML_REMOVED] q;
int work()
{
while(!q.empty())
{
int v = q.front(); q.pop();
if(v == 0) return d[v + 1000];
for(int it=-1000;it<=1000;it++)
if(s[it+1000])
{
int nxtv = it + v;
if(nxtv >= -m && nxtv <= m && d[nxtv + 1000] == 0){
q.push(nxtv);
d[nxtv+1000] += d[v + 1000] + 1;
}
}
}
return -1;
}
int main()
{
freopen(“soda.in”,”r”,stdin);
freopen(“soda.out”,”w”,stdout);
scanf(“%d%d%d”, &k, &n, &m);
for(int i = 0; i < k; i++){
int x;
scanf(“%d”, &x);
x -= n;
s[x+1000] = 1;
q.push(x);
d[x+1000] = 1;
}
printf(“%d\n”, work());
return 0;
}