#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int profit[n];
    int amount[n];
    int ascamount[n];
    for(int i=0; i<n; i++){
        cin>>profit[i];
    }
    for(int i=0; i<n; i++){
        cin>>amount[i];
    }
    for(int i=0; i<n; i++){
        ascamount[i] = profit[i]/amount[i];
    }
    int temp;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            if(ascamount[i]<ascamount[j]){
                temp = ascamount[i];
                ascamount[i]=ascamount[j];
                ascamount[j] = temp;
                
                temp = profit[i];
                profit[i]=profit[j];
                profit[j]=temp;
                
                temp = amount[i];
                amount[i]=amount[j];
                amount[j]=temp;
            }
        }
    }
    int a;
    cin>>a;
    int sum=0;
    for(int i=0; i<n; i++){
        if(ascamount<=a){
            sum = sum + profit[i];
            a = a-amount[i];
        }
        else{
            sum = sum + a*(profit[i]/amount[i]);
        }
    }
}