#include <cstdio>
const double eps=1e-6;

int n;

double a[100005];

inline double min(double a,double b) {
	return a<b?a:b;
}

double calc(double x) {
	double ans=0;
	for(int i=1;i<=n;i++) {
		ans+=x+a[i]-min(a[i],x*2.0);
	}
	//printf("%.6lf %.6lf\n",x,ans);
	return ans;
}

int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%lf",&a[i]);
	}
	double l=0.0,r=1e9;
	while((r-l)>eps) {
		double a=l+(r-l)/3.0;
		double b=r-(r-l)/3.0;
		if(calc(a)<calc(b)) {
			r=b;
		}else {
			l=a;
		}
	}
	printf("%.6lf\n",min(calc(l),calc(r))/(1.0*n));
	return 0;
}
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;

ll x[100005],y[100005];
int main() {
  int n;
  cin >> n;
  rep(i,n){
    int a;
    cin >> a;
    x[a]++;
  }
  vector<int> b(n);
  rep(i,n) cin >> b[i];
  rep(i,n){
    int c;
    cin >> c;
    --c;
    y[b[c]]++;
  }
  ll ans = 0;
  rep(i,n+1) ans += x[i]*y[i];
  cout << ans << endl;
}
