1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4 #define rep(i,l,r) for(int i=l; i<=r; i++)
5 #define clr(x,y) memset(x,y,sizeof(x))
6 using namespace std;
7 int n,m,begin,c[60];
8 bool f[60][1010];
9 inline int read(){
10 int ans = 0, f = 1;
11 char c = getchar();
12 while (!isdigit(c)){
13 if (c == ‘-‘) f = -1;
14 c = getchar();
15 }
16 while (isdigit(c)){
17 ans = ans * 10 + c - ‘0‘;
18 c = getchar();
19 }
20 return ans * f;
21 }
22 int main(){
23 n = read(); begin = read(); m = read();
24 rep(i,1,n) c[i] = read();
25 clr(f,0); f[0][begin] = 1;
26 rep(i,1,n){
27 rep(j,0,m){
28 if (j + c[i] <= m)
29 if (f[i-1][j+c[i]]) f[i][j] = 1;
30 if (j - c[i] >= 0)
31 if (f[i-1][j-c[i]]) f[i][j] = 1;
32 }
33 }
34 for(int i=m; i>=0; i--) if (f[n][i]){
35 printf("%d\n",i); return 0;
36 }
37 printf("-1\n");
38 return 0;
39 }