#include<bits/stdc++.h>
using namespace std;
bool cmp(int n1,int n2){
return n1<n2;
}
int main(){
int n;
long long int t;
cin >> n>> t;
vector<int> arr;
int num;
for(int i = 0;i<n;i++){
cin >> num;
arr.push_back(num);
}
sort(arr.begin(),arr.end(),cmp);
int sum = 0;
for(auto iter = arr.begin();iter!=arr.end();iter++){
int ans = sum + *iter;
if(ans >= t) {
cout << sum + arr[arr.size()-1];
return 0;
}
else{
sum = ans;
}
}
cout << sum;
return 0;
}

京公网安备 11010502036488号