#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define imax INT_MAX
#define llmax LLONG_MAX
#define int long long
#define ld long double
#define pq priority_queue
#define inf 1e18
#define all(v) v.begin,v.end()
const long long INF=1e18;
const int MAXN = 300005;
const int MOD=1e9+7;
typedef long long ll;
//8.30
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,cnth=0,cntv=0;cin>>n;
vector<int> vert(n),hor(n);
int vs,hs,vm=-1,hm=-1;
for(int i=0;i<n;i++){
cin>>vert[i];
if(i==0)continue;
if(vert[i]==vm)cntv++;
if(vert[i]>vm){vm=vert[i];cntv=1;vs=i;}
}
for(int i=0;i<n;i++){
cin>>hor[i];
if(i==0)continue;
if(hor[i]==hm)cnth++;
if(hor[i]>hm){hm=hor[i];cnth=1;hs=i;}
}
int res=0,num;
if(vm>hm){
num=vm;
res=(n-vs)*(n-1)+cntv;
}else if(hm>vm){
num=hm;
res=(n-hs)*(n-1)+cnth;
}else if(hm==vm){
num=hm;
res=((n-vs)*(n-1)) + ((vs-1)*(n-hs))+cnth+cntv;
}
if(vert[0]==num)res++;
cout<<num<<" "<<res;
return 0;
}