#include #include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() #define ll long long #define ld long double #define INF 1000000000000000000 typedef pair pll; typedef pair pint; vector A, B; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; A.resize(N), B.resize(N); rep(i, N) { cin >> A[i]; } rep(i, N) { cin >> B[i]; } ld med; sort(all(A)); if (A.size() % 2 == 0) { med = (A[A.size() / 2 - 1] + A[A.size() / 2]) / 2; } else { med = A[A.size() / 2]; } ld ans = 0; rep(i, N) { ans += B[i] * abs(A[i] - med); } cout << fixed << setprecision(10) << med << " " << ans << endl; }