借放
#include <bits/stdc++.h> //e465
using namespace std;
int main(){
int m, s, n, sum = 0;
cin >> m >> s >> n;
int a[n];
for(int i = 0;i < n;i++){
cin >> a[i];
sum += a[i];
}
int limit = m - s; //能保留越多越好
vector<int> dp(200001, 0);
for(int i = 0;i < n;i++){
for(int j = limit;j >= a[i];j--){
dp[j] = max(dp[j],dp[j-a[i]]+a[i]); //b184貨櫃問題倒過來
}
}
cout << sum - dp[limit]; //全部-保留住的 20-(1+2+2)=15
}