#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int n; cin>>n; vector a(n),b(n); rep(i,n) cin>>a[i]; rep(i,n) cin>>b[i]; double m; if(n&1){ m = a[n/2]; }else{ m = (a[n/2-1]+a[n/2])/2.0; } double fx = 0; rep(i,n){ fx += b[i] * abs(m - a[i]); } cout << m << " " << (int)fx << endl; return 0; }