#include using namespace std; typedef long long ll; signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); ll n; cin>>n; map mp; ll sum = 0; for(ll i=0;i>a; sum += a; mp[a]++; } ll q; cin>>q; while(q--){ ll a; cin>>a; vector era; vector cnt; auto itr = mp.lower_bound(a); if(itr == mp.end()){ cout << sum << "\n"; continue; } while(itr != mp.end()){ era.push_back(itr->first); cnt.push_back(itr->second); itr++; } for(ll i=0;i