#include<bits/stdc++.h>
using namespace std;
using ll = long long;
vector<ll> calculate_costs(vector<int> w, vector<int> a, vector<int> b, vector<int> e){
int n = w.size();
vector<ll> ans;
sort(w.begin(), w.end());
for (auto &d : e){
vector<pair<ll, ll>> dp(n);
dp[0] = {a[0], 1000000000000000000};
for (int i = 1; i < n; i++){
dp[i].first = min(dp[i - 1].first, dp[i - 1].second);
dp[i].second = dp[i - 1].first - a[0] + b[0] + b[i];
for (int j = 1; j < i; j++){
dp[i].second = min(dp[i].second, dp[j].first - a[j] + b[j] + b[i]);
}
}
ans.push_back(min(dp[n - 1].first, dp[n - 1].second));
}
return ans;
}