import java.util.*;
import java.lang.*;
import java.io.*;
class CD
{
{
int[][] d = new int[210][110];
short[] arr = new short[110];
Scanner in
= new Scanner
(System.
in); while (in.hasNext()){
short n = in.nextShort();
short k = in.nextShort();
for (int i=1; i<=k; i++) arr[i] = in.nextShort();
for (int i=1; i<=k; i++)
for (int j=0; j<=n; j++)
if (arr[i]<=j){
if (d[j][i-1]< arr[i]+d[j-arr[i]][i-1]) d[j][i]=arr[i]+d[j-arr[i]][i-1];
else d[j][i]=d[j][i-1];
}
else d[j][i]=d[j][i-1];
System.
out.
printf("sum: " + d
[n
][k
]); }
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CmNsYXNzIENECnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCWludFtdW10gZCA9IG5ldyBpbnRbMjEwXVsxMTBdOwoJCXNob3J0W10gYXJyID0gbmV3IHNob3J0WzExMF07CgkJU2Nhbm5lciBpbiA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7IAoJCXdoaWxlIChpbi5oYXNOZXh0KCkpewoJCQlzaG9ydCBuID0gaW4ubmV4dFNob3J0KCk7CQoJCQlzaG9ydCBrID0gaW4ubmV4dFNob3J0KCk7CgkJCWZvciAoaW50IGk9MTsgaTw9azsgaSsrKSBhcnJbaV0gPSBpbi5uZXh0U2hvcnQoKTsKCQkJZm9yIChpbnQgaT0xOyBpPD1rOyBpKyspCgkJCQlmb3IgKGludCBqPTA7IGo8PW47IGorKykKCQkJCQlpZiAoYXJyW2ldPD1qKXsKCQkJCQkJaWYgKGRbal1baS0xXTwgYXJyW2ldK2Rbai1hcnJbaV1dW2ktMV0pIGRbal1baV09YXJyW2ldK2Rbai1hcnJbaV1dW2ktMV07CgkJCQkJCWVsc2UgZFtqXVtpXT1kW2pdW2ktMV07CgkJCQkJfQoJCQkJCWVsc2UgZFtqXVtpXT1kW2pdW2ktMV07CgkJCQkJU3lzdGVtLm91dC5wcmludGYoInN1bTogIiArIGRbbl1ba10pOwoJCX0KCX0KfQ==