#include <iostream>
#include <vector>
#include <algorithm> using namespace std; int main(){
int n,d;
cin >> n >>d;
vector<int>a(n);
for(int i = ; i < n ; ++ i )
cin >>a[i];
int m;
cin >> m;
sort(a.begin(),a.end());
int sum = ;
if(m <=n){
for(int i = ; i < m; ++ i)
sum+=a[i];
}
else{
for(int i = ; i < n; ++ i)
sum+=a[i];
sum -= d*(m-n);
}
cout<<sum<<endl;
return ;
}
相关文章
- Codeforces Round #215 (Div. 2) A. Sereja and Coat Rack
- Codeforces Round #524 (Div. 2) A. Petya and Origami
- Codeforces Round #382 (Div. 2) A. Ostap and Grasshopper bfs
- Codeforces Round #353 (Div. 2) A. Infinite Sequence 水题
- Codeforces Round #188 (Div. 2) A. Even Odds 水题
- Codeforces Round #277 (Div. 2) A. Calculating Function 水题
- 水题 Codeforces Round #303 (Div. 2) A. Toy Cars
- Codeforces Round #303 (Div. 2) A. Toy Cars 水题
- Codeforces Round #345 (Div. 2)【A.模拟,B,暴力,C,STL,容斥原理】
- Codeforces Round #272 (Div. 2)-A. Dreamoon and Stairs