#include <cstdio>
using namespace std;
short d[210][110];
short arr[110];
short max (short a, short b) {
return a<b ? b : a;
}
int main() {
int n;
while (scanf("%d", &n)>0){
int k;
scanf("%d", &k);
for (int i=1; i<=k; i++) scanf("%d", &arr[i]);
for (int i=1; i<=k; i++)
for (int j=0; j<=n; j++)
if (arr[i]<=j) d[j][i]=max(d[j][i-1], arr[i]+d[j-arr[i]][i-1]);
else d[j][i]=d[j][i-1];
printf("sum:%d\n", d[n][k]);
}
return 0;
}
I2luY2x1ZGUgPGNzdGRpbz4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKIApzaG9ydCBkWzIxMF1bMTEwXTsKc2hvcnQgYXJyWzExMF07CiAKc2hvcnQgbWF4IChzaG9ydCBhLCBzaG9ydCBiKSB7CglyZXR1cm4gYTxiID8gYiA6IGE7CQp9CmludCBtYWluKCkgewoJaW50IG47Cgl3aGlsZSAoc2NhbmYoIiVkIiwgJm4pPjApewoJCWludCBrOwoJCXNjYW5mKCIlZCIsICZrKTsKCQlmb3IgKGludCBpPTE7IGk8PWs7IGkrKykgc2NhbmYoIiVkIiwgJmFycltpXSk7CgkJZm9yIChpbnQgaT0xOyBpPD1rOyBpKyspCgkJCWZvciAoaW50IGo9MDsgajw9bjsgaisrKQoJCQkJaWYgKGFycltpXTw9aikgZFtqXVtpXT1tYXgoZFtqXVtpLTFdLCBhcnJbaV0rZFtqLWFycltpXV1baS0xXSk7CgkJCQllbHNlIGRbal1baV09ZFtqXVtpLTFdOwoJCXByaW50Zigic3VtOiVkXG4iLCBkW25dW2tdKTsKCX0KCXJldHVybiAwOwp9