#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> p(n); rep(i,n) cin>>p[i].first; rep(i,n) cin>>p[i].second; sort(p.begin(),p.end()); long double x; if(n&1) x = p[n/2].first; else x = (p[n/2-1].first+p[n/2].first)/2.0; long double fx = 0.0; rep(i,n){ fx += p[i].second * abs(p[i].first - x); } cout.precision(9); cout << x << " " << (int)fx << endl; return 0; }