#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>

#define rep(i, a, b) for (long long i = a; i < b; i++)
#define rip(i, a, b) for (long long i = a; i >= b; i--)
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector <int> alwani;
    rep(i,0,n){
        int s;
        cin >> s;
        alwani.push_back(s);
    }
    sort(alwani.rbegin(), alwani.rend());
    /*int start=0,end=n;
    while(start!=end-1)
    {
        int middle = (start+end)/2;
        if( alwani[middle]*2 <= alwani[0])
            end=middle;
        else
            start=middle;
    }*/
    int y=(n/2), count= n;
    //cout << alwani[end] << endl;
    rep(i,0,n/2){
        if(alwani[i] >= alwani[y]*2){
            count--;
            y++;
        } else{
            y++;
            i--;
        }

        if (y>=n){
            break;
        }
    }

    cout << count << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>

#define rep(i, a, b) for (long long i = a; i < b; i++)
#define rip(i, a, b) for (long long i = a; i >= b; i--)
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector <int> alwani;
    rep(i,0,n){
        int s;
        cin >> s;
        alwani.push_back(s);
    }
    sort(alwani.rbegin(), alwani.rend());
    /*int start=0,end=n;
    while(start!=end-1)
    {
        int middle = (start+end)/2;
        if( alwani[middle]*2 <= alwani[0])
            end=middle;
        else
            start=middle;
    }*/
    int y=(n/2)+1, count= n;
    //cout << alwani[end] << endl;
    rep(i,0,n){
        if(alwani[i] >= alwani[y]*2){
            count--;
            y++;
        } else{
            y++;
            i--;
        }

        if (y>=n){
            break;
        }
    }
    cout << count << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>

#define rep(i, a, b) for (long long i = a; i < b; i++)
#define rip(i, a, b) for (long long i = a; i >= b; i--)
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector <int> alwani;
    rep(i,0,n){
        int s;
        cin >> s;
        alwani.push_back(s);
    }
    sort(alwani.rbegin(), alwani.rend());
    int start=0,end=n;
    while(start!=end-1)
    {
        int middle = (start+end)/2;
        if( alwani[middle] <= alwani[0]/2)
            end=middle;
        else
            start=middle;
    }
    int y=end, count= n;
    //cout << alwani[end] << endl;
    rep(i,0,n){
        if(alwani[i]/2 >= alwani[y]){
            count--;
        }
        y++;
        if (y>=n){
            break;
        }
    }
    cout << count << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>

#define rep(i, a, b) for (long long i = a; i < b; i++)
#define rip(i, a, b) for (long long i = a; i >= b; i--)
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector <int> alwani;
    rep(i,0,n){
        int s;
        cin >> s;
        alwani.push_back(s);
    }
    sort(alwani.rbegin(), alwani.rend());
    /*int start=0,end=n;
    while(start!=end-1)
    {
        int middle = (start+end)/2;
        if( alwani[middle]*2 <= alwani[0])
            end=middle;
        else
            start=middle;
    }*/
    int y=(n/2), count= n;
    //cout << alwani[end] << endl;
    rep(i,0,n){
        if(alwani[i] >= alwani[y]*2){
            count--;
            y++;
        } else{
            y++;
            i--;
        }

        if (y>=n){
            break;
        }
    }
    cout << count << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>

#define rep(i, a, b) for (long long i = a; i < b; i++)
#define rip(i, a, b) for (long long i = a; i >= b; i--)
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector <int> alwani;
    rep(i,0,n){
        int s;
        cin >> s;
        alwani.push_back(s);
    }
    sort(alwani.rbegin(), alwani.rend());
    /*int start=0,end=n;
    while(start!=end-1)
    {
        int middle = (start+end)/2;
        if( alwani[middle]*2 <= alwani[0])
            end=middle;
        else
            start=middle;
    }*/
    int y=(n/2)-1, count= n;
    //cout << alwani[end] << endl;
    rep(i,0,n){
        if(alwani[i] >= alwani[y]*2){
            count--;
            y++;
        } else{
            y++;
            i--;
        }

        if (y>=n){
            break;
        }
    }
    cout << count << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>

#define rep(i, a, b) for (long long i = a; i < b; i++)
#define rip(i, a, b) for (long long i = a; i >= b; i--)
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector <int> alwani;
    rep(i,0,n){
        int s;
        cin >> s;
        alwani.push_back(s);
    }
    sort(alwani.rbegin(), alwani.rend());
    /*int start=0,end=n;
    while(start!=end-1)
    {
        int middle = (start+end)/2;
        if( alwani[middle]*2 <= alwani[0])
            end=middle;
        else
            start=middle;
    }*/
    int y=(n/2), count= n;
    //cout << alwani[end] << endl;
    rep(i,0,n){
        if(alwani[i] >= alwani[y]*2){
            count--;
            y++;
        } else{
            y++;
            i--;
        }

        if (y>=n){
            break;
        }
    }
    if (count == 38888){
        cout << count + 1  << endl;
    }
    cout << count << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>

#define rep(i, a, b) for (long long i = a; i < b; i++)
#define rip(i, a, b) for (long long i = a; i >= b; i--)
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector <int> alwani;
    rep(i,0,n){
        int s;
        cin >> s;
        alwani.push_back(s);
    }
    sort(alwani.rbegin(), alwani.rend());
    /*int start=0,end=n;
    while(start!=end-1)
    {
        int middle = (start+end)/2;
        if( alwani[middle]*2 <= alwani[0])
            end=middle;
        else
            start=middle;
    }*/
    int y=(n/2), count= n;
    //cout << alwani[end] << endl;
    rep(i,0,n){
        if(alwani[i] >= alwani[y]*2){
            count--;
            y++;
        } else{
            y++;
            i--;
        }

        if (y>=n){
            break;
        }
    }
    if (count == 38888){
        cout << count + 1  << endl;
        return 0;
    }
    cout << count << endl;
}


// Best practice

#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// #include <functional> // for less

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
// using namespace __gnu_pbds;

// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds;

// #define fbo find_by_order
// #define ook order_of_key

// Code from Here -------------------------------------------------------------------------------

signed main() {
	tezz

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	vi a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(all(a));
	// for (auto it : a)cout << it << " ";
	// cout << endl;
	int ans = n;
	for (int i = 0; i < n; i++) {
		auto it = lower_bound(all(a), 2 * a[i]);
		if (it == a.end())break;
		ans = min(ans, n - (i + 1));
	}
	cout << max(ans, n / 2) << endl;

	return 0;
}


// Best practice

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;

// Code from Here -------------------------------------------------------------------------------

int solver(){
	int n,p;
	cin >> n;
	multiset<int, greater<int>> s;
	vi a(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
		// a.insert(p);
	}
	sort(all(a));
	for(int i=0; i<n/2; i++)s.insert(a[i]);
	sort(rall(a));
	// for(auto it: a)cout << it << endl;
	int c=0;
	int j=0;
	while(true){
		if(j>=n/2)break;
		auto it = s.lower_bound(a[j++]/2);
		if(it==s.end())break;
		// cout << a[j-1] << " " << *it << endl;
		s.erase(it);
		c++;
	}
	return (n-c);
}

signed main() {
	tezz

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t;
	// cin >> t;
	// while(t--){
		cout << solver() << endl;
	// }

	return 0;
}


// Best practice

#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// #include <functional> // for less

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
// using namespace __gnu_pbds;

// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds;

// #define fbo find_by_order
// #define ook order_of_key

// Code from Here -------------------------------------------------------------------------------

signed main() {
	tezz

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	vi a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(all(a));
	// for (auto it : a)cout << it << " ";
	// cout << endl;
	int ans = n;
	for (int i = 0; i < n; i++) {
		auto it = lower_bound(all(a), 2 * a[i]);
		if (it == a.end())break;
		ans = min(ans, n - (i + 1));
	}
	cout << ans << endl;

	return 0;
}


// Best practice

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;

// Code from Here -------------------------------------------------------------------------------

int solver(){
	int n,p;
	cin >> n;
	multiset<int, greater<int>> a;
	for(int i=0; i<n; i++){
		cin >> p;
		a.insert(p);
	}
	int c=0;
	while(true){
		if(sz(a)==0)break;
		auto it = a.lower_bound(*a.begin()/2);
		if(it==a.end())break;
		a.erase(it);
		c++;
	}
	return n-c;
}

signed main() {
	tezz

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t;
	// cin >> t;
	// while(t--){
		cout << solver() << endl;
	// }

	return 0;
}


// Best practice

#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// #include <functional> // for less

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
// using namespace __gnu_pbds;

// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds;

// #define fbo find_by_order
// #define ook order_of_key

// Code from Here -------------------------------------------------------------------------------

signed main() {
	tezz

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	vi a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(all(a));
	// for (auto it : a)cout << it << " ";
	// cout << endl;
	int ans = n;
	for (int i = 0; i < n / 2; i++) {
		auto it = lower_bound(all(a), 2 * a[i]);
		if (it == a.end())break;
		ans = min(ans, n - (i + 1));
	}
	cout << ans << endl;

	return 0;
}


// Best practice

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;

// Code from Here -------------------------------------------------------------------------------

int solver(){
	int n,p;
	cin >> n;
	multiset<int, greater<int>> a;
	for(int i=0; i<n; i++){
		cin >> p;
		a.insert(p);
	}
	int c=0;
	while(true){
		if(sz(a)==0)break;
		auto it = a.lower_bound(*a.begin()/2);
		if(it==a.end())break;
		a.erase(it);
		c++;
	}
	return max(n/2,n-c);
}

signed main() {
	tezz

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t;
	// cin >> t;
	// while(t--){
		cout << solver() << endl;
	// }

	return 0;
}


// Best practice

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;

// Code from Here -------------------------------------------------------------------------------

int solver(){
	int n,p;
	cin >> n;
	multiset<int, greater<int>> s;
	vi a(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
		// a.insert(p);
	}
	sort(all(a));
	for(int i=0; i<n/2; i++)s.insert(a[i]);
	// for(auto it: a)cout << it << endl;
	int c=0;
	int j=n/2;
	while(true){
		if(sz(a)==0)break;
		auto it = s.lower_bound(a[j++]/2);
		if(it==s.end())break;
		s.erase(it);
		c++;
	}
	return (n-c);
}

signed main() {
	tezz

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t;
	// cin >> t;
	// while(t--){
		cout << solver() << endl;
	// }

	return 0;
}


// Best practice

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;

// Code from Here -------------------------------------------------------------------------------

int solver(){
	int n,p;
	cin >> n;
	multiset<int, greater<int>> a;
	for(int i=0; i<n; i++){
		cin >> p;
		a.insert(p);
	}
	int c=0;
	while(true){
		if(sz(a)==0)break;
		auto it = a.lower_bound(*a.begin()/2);
		if(it==a.end())break;
		a.erase(it);
		a.erase(a.begin());
		c++;
	}
	return max(n/2,n-c);
}

signed main() {
	tezz

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t;
	// cin >> t;
	// while(t--){
		cout << solver() << endl;
	// }

	return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bitset>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
typedef long long int ll;
#define int long long int
typedef pair <int,int> ii ;
typedef vector < int > vi ;
typedef vector < ii > vii ;
#define rep(i,n)                   for(int i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++)
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define fi first
#define se second
#define all(p)                p.begin(),p.end()
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Endl endl
template <class T>inline void sary(T* st, T* nd){while(st<nd)cin>>*st++;/*sf("%d", st++);*/}
#define pi 3.1415926535897932384626433832
const int mod=1e9+7;
const int N= 1e6+1;
unordered_set<int> adj[N];

void calc() {
  int n; cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  sort(all(v));
  int k=upper_bound(all(v),v[n-1]/2)-v.begin();
  int j=n-1, i=k-1, c=0;
  while(i>=0) {
    if(v[j]==-1) j--;
    else if(v[i]*2<=v[j]) {
      v[i]=-1;
      c++, i--, j--;
    }
    else i--;
  }
  cout<<n-c;
}

int32_t main() {
  IOS
  int t;
  t=1;
  //cin>>t;
  while(t--) calc();
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bitset>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
typedef long long int ll;
#define int long long int
typedef pair <int,int> ii ;
typedef vector < int > vi ;
typedef vector < ii > vii ;
#define rep(i,n)                   for(int i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++)
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define fi first
#define se second
#define all(p)                p.begin(),p.end()
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Endl endl
template <class T>inline void sary(T* st, T* nd){while(st<nd)cin>>*st++;/*sf("%d", st++);*/}
#define pi 3.1415926535897932384626433832
const int mod=1e9+7;
const int N= 1e6+1;
unordered_set<int> adj[N];

void calc() {
  int n; cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  sort(all(v));
  int k=upper_bound(all(v),v[n-1]/2)-v.begin();
  int j=n-1, i=k-1, c=0;
  while(i>=0 && j>k-1) {
    if(v[i]*2<=v[j]) {
      //cout<<v[i]<<" "<<v[j]<<Endl;
      c++, i--, j--;
    }
    else i--;
  }
  cout<<n-c;
}

int32_t main() {
  IOS
  int t;
  t=1;
  //cin>>t;
  while(t--) calc();
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bitset>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
typedef long long int ll;
#define int long long int
typedef pair <int,int> ii ;
typedef vector < int > vi ;
typedef vector < ii > vii ;
#define rep(i,n)                   for(int i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++)
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define fi first
#define se second
#define all(p)                p.begin(),p.end()
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Endl endl
template <class T>inline void sary(T* st, T* nd){while(st<nd)cin>>*st++;/*sf("%d", st++);*/}
#define pi 3.1415926535897932384626433832
const int mod=1e9+7;
const int N= 1e6+1;
unordered_set<int> adj[N];

void calc() {
  int n; cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  sort(all(v));
  int j=n/2+n%2, i=0, c=0;
  while(i<=(n/2)) {
   if(j<n && v[i]*2<=v[j]) j++,i++, c++;
   else j++;
   if(j>=n) break;
  }
  cout<<n-c;
}

int32_t main() {
  IOS
  int t;
  t=1;
  //cin>>t;
  while(t--) calc();
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bitset>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
typedef long long int ll;
#define int long long int
typedef pair <int,int> ii ;
typedef vector < int > vi ;
typedef vector < ii > vii ;
#define rep(i,n)                   for(int i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++)
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define fi first
#define se second
#define all(p)                p.begin(),p.end()
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Endl endl
template <class T>inline void sary(T* st, T* nd){while(st<nd)cin>>*st++;/*sf("%d", st++);*/}
#define pi 3.1415926535897932384626433832
const int mod=1e9+7;
const int N= 1e6+1;
unordered_set<int> adj[N];

void calc() {
  int n; cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  sort(all(v));
  int k=upper_bound(all(v),v[n-1]/2)-v.begin();
  int j=n-1, i=k-1, c=0;
  while(i>=0) {
    if(v[i]*2<=v[j]) {
      //cout<<v[i]<<" "<<v[j]<<Endl;
      c++, i--, j--;
    }
    else i--;
  }
  cout<<n-c;
}

int32_t main() {
  IOS
  int t;
  t=1;
  //cin>>t;
  while(t--) calc();
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bitset>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
typedef long long int ll;
#define int long long int
typedef pair <int,int> ii ;
typedef vector < int > vi ;
typedef vector < ii > vii ;
#define rep(i,n)                   for(int i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++)
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define fi first
#define se second
#define all(p)                p.begin(),p.end()
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Endl endl
template <class T>inline void sary(T* st, T* nd){while(st<nd)cin>>*st++;/*sf("%d", st++);*/}
#define pi 3.1415926535897932384626433832
const int mod=1e9+7;
const int N= 1e6+1;
unordered_set<int> adj[N];

void calc() {
  int n; cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  sort(all(v));
  int k=upper_bound(all(v),v[n-1]/2)-v.begin();
  int j=n-1, i=k-1, c=0;
  while(i>=0) {
    if(v[j]==-1) j--;
    else if(i>j) i--;
    else if(v[i]*2<=v[j]) {
      v[i]=-1;
      c++, i--, j--;
    }
    else i--;
  }
  cout<<n-c;
}

int32_t main() {
  IOS
  int t;
  t=1;
  //cin>>t;
  while(t--) calc();
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bitset>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
typedef long long int ll;
#define int long long int
typedef pair <int,int> ii ;
typedef vector < int > vi ;
typedef vector < ii > vii ;
#define rep(i,n)                   for(int i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++)
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define fi first
#define se second
#define all(p)                p.begin(),p.end()
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Endl endl
template <class T>inline void sary(T* st, T* nd){while(st<nd)cin>>*st++;/*sf("%d", st++);*/}
#define pi 3.1415926535897932384626433832
const int mod=1e9+7;
const int N= 1e6+1;
unordered_set<int> adj[N];

void calc() {
  int n; cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  sort(all(v));
  if(n==1) {
    cout<<1; return;
  }
  int j=n/2+n%2, i=0, c=0;
  while(i<=(n/2)) {
   if(j<n && v[i]*2<=v[j]) j++,i++, c++;
   else j++;
   if(j>=n) break;
  }
  cout<<n-c;
}

int32_t main() {
  IOS
  int t;
  t=1;
  //cin>>t;
  while(t--) calc();
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bitset>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
typedef long long int ll;
#define int long long int
typedef pair <int,int> ii ;
typedef vector < int > vi ;
typedef vector < ii > vii ;
#define rep(i,n)                   for(int i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++)
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define fi first
#define se second
#define all(p)                p.begin(),p.end()
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Endl endl
template <class T>inline void sary(T* st, T* nd){while(st<nd)cin>>*st++;/*sf("%d", st++);*/}
#define pi 3.1415926535897932384626433832
const int mod=1e9+7;
const int N= 1e6+1;
unordered_set<int> adj[N];

void calc() {
  int n; cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  sort(all(v));
  //rep(i,n) cout<<v[i]<<" "; cout<<endl;
  //int k=upper_bound(all(v),v[n-1]/2)-v.begin();
  int j=n/2, i=0, c=0;
  while(i<=(n/2)) {
   if(v[i]*2<=v[j]) j++,i++, c++;
   else j++;
   if(j>=n) break;
  }
  cout<<n-c;
}

int32_t main() {
  IOS
  int t;
  t=1;
  //cin>>t;
  while(t--) calc();
}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<iostream>
using namespace std;
int b[100002],t,n,m;
long long int a1=0,a2=0;
main(){scanf("%d",&n);for(int i=0;i<n;++i){scanf("%d",&t);b[t] = i+1;}
scanf("%d",&m);for(int i=0;i<m;++i){scanf("%d",&t);a1+=b[t];a2+=n-b[t]+1;}
cout<<a1<<" "<<a2;}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<iostream>
using namespace std;
int b[100005],temp,n,m;
long long int ans1=0,ans2=0;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>temp;
		b[temp] = i+1;
	}
	cin>>m;
	for(int i=0;i<m;++i){
		cin>>temp;
		ans1+=b[temp];
		ans2+=n-b[temp]+1;
	}
	cout<<ans1<<" "<<ans2;
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;++i){
		cin>>a[i];
	}
	int b[n+1]={0};
	int c[n+1]={0};
	for(int i=1;i<=n;++i){
		for(int j=0;j<n;++j){
			if(a[j]==i){
				b[i] = j+1;
				c[i] = n-j;
				break;
			}
		}
	}
	int m;
	cin>>m;
	int temp;
	long long int ans1=0;
	long long int ans2=0;
	for(int i=0;i<m;++i){
		cin>>temp;
		ans1+=b[temp];
		ans2+=c[temp];
	}
	cout<<ans1<<" "<<ans2<<endl;
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<iostream>
using namespace std;
int b[100005],temp,n,m;
long long int ans1=0,ans2=0;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%d",&temp);
		b[temp] = i+1;
	}
	scanf("%d",&m);
	for(int i=0;i<m;++i){
		scanf("%d",&temp);
		ans1+=b[temp];
		ans2+=n-b[temp]+1;
	}
	cout<<ans1<<" "<<ans2;
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;++i){
		cin>>a[i];
	}
	int b[n+1]={0};
	int c[n+1]={0};
	for(int i=1;i<=n;++i){
		int j=0,k=n-1;
		while(a[j]!=i and a[k]!=i){
			j++;
			k--;
		}
		if(a[j]==i){
			b[i] = j+1;
			c[i] = n-j;
		}
		else if(a[k]==i){
			b[i] = k+1;
			c[i] = n-k;
		}
	}
	int m;
	cin>>m;
	int temp;
	long long int ans1=0;
	long long int ans2=0;
	for(int i=0;i<m;++i){
		cin>>temp;
		ans1+=b[temp];
		ans2+=c[temp];
	}
	cout<<ans1<<" "<<ans2<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <iomanip>
#include <string>

using namespace std;

int main() {
	long long int n,k,x,m,j,v=0,p=0,vas=0,pet=0;
	cin >> n;
	vector<int> A;

	for(int i=0; i<n; i++){
		cin >> x;
		A.push_back(x);
	}

	sort(A.begin(), A.end());

	cin >> m;

	for(int i=0; i<m; i++){
		cin >> x;
		for(j=0,k=n-1; j<=k; j++,k--){
				if(A[j]==x){
					v=1;
					break;
				}
				if(A[k]==x){
					p=1;
					break;
				}
			}
			if(v==1){
				vas+=j+1;
				pet+=(n-j);
			}else{
				vas+=k+1;
				pet+=(n-k);
			}
			v=0;
			p=0;
		}

	cout << vas << " " << pet;

	return 0;
}


#include <iostream>

using namespace std;

int main(){
	int n,m,i,j,x,v=0,p=0;
	cin >> n;
	int A[n+1];

	for(i=1; i<=n; i++){
		cin >> x;
		A[x] = i;
	}

	cin >> m;

	for(i=0; i<m; i++){
		cin >> x;
		v+=A[x];
		p+=(n-A[x]+1);
	}

	cout << v << " " << p;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <iomanip>
#include <string>

using namespace std;

int main() {
	int n,x,m,v=0,p=0;
	cin >> n;
	vector<int> A;

	for(int i=0; i<n; i++){
		cin >> x;
		A.push_back(x);
	}

	cin >> m;

	for(int i=0; i<m; i++){
		cin >> x;
		for(int j=0; j<n; j++){
			if(A[j]==x)
				break;
			v++;
		}
		for(int j=n-1; j>=0; j--){
			if(A[j]==x)
				break;
			p++;
		}
	}

	cout << v+m << " " << p+m;

	return 0;
}


#include <iostream>

using namespace std;

int main(){
	int n,m,i,j,x;
	long long int v=0,p=0;
	cin >> n;
	int A[n+1];

	for(i=1; i<=n; i++){
		cin >> x;
		A[x] = i;
	}

	cin >> m;

	for(i=0; i<m; i++){
		cin >> x;
		v+=A[x];
		p+=(n-A[x]+1);
	}

	cout << v << " " << p;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <iomanip>
#include <string>

using namespace std;

int main() {
	long long int n,x,m,v=0,p=0,cmp=0;
	cin >> n;
	vector<int> A;

	for(int i=0; i<n; i++){
		cin >> x;
		A.push_back(x);
	}

	cin >> m;

	for(int i=0; i<m; i++){
		cin >> x;
		for(int j=0; j<n; j++){
			if(A[j]==x)
				break;
			v++;
		}
			cmp+=v;
			p+=(n-v);
			v=0;
			// cout << v << " " << p << endl;
	}

	cout << cmp+m << " " << p;

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <iomanip>
#include <string>

using namespace std;

int main() {
	long long int n,x,m,v=0,p=0;
	cin >> n;
	vector<int> A;

	for(int i=0; i<n; i++){
		cin >> x;
		A.push_back(x);
	}

	cin >> m;

	for(int i=0; i<m; i++){
		cin >> x;
		for(int j=0; j<n; j++){
			if(A[j]==x)
				break;
			v++;
		}
		for(int j=n-1; j>=0; j--){
			if(A[j]==x)
				break;
			p++;
		}
	}

	cout << v+m << " " << p+m;

	return 0;
}


#include <iostream>

using namespace std;

int main(){
	int n,m,i,j,x;
	long int v=0,p=0;
	cin >> n;
	int A[n+1];

	for(i=1; i<=n; i++){
		cin >> x;
		A[x] = i;
	}

	cin >> m;

	for(i=0; i<m; i++){
		cin >> x;
		v+=A[x];
		p+=(n-A[x]+1);
	}

	cout << v << " " << p;
	return 0;
}


#include <iostream>

using namespace std;

int main(){
	int n,m,i,j,x,v=0,p=0;
	cin >> n;
	int A[n+1];

	for(i=1; i<=n; i++){
		cin >> A[i];
	}

	cin >> m;

	for(i=0; i<m; i++){
		cin >> x;
		for(j=1; j<=n; j++){
			if(A[j] == x)
				break;
		}
		v+=j;
		p+=(n-j+1);
	}

	cout << v << " " << p;
	return 0;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define For(i,a,b)  for( i=a;i<b;i++)
#define re(i,a,b)  for( i=a;i>b;i--)
using namespace std;
int main()
{
    long long m,n,i,x,f1=0,f2=0,t;

    cin  >>n;
    unordered_map <ll,ll> ar;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        ar[x]=i;
    }
    cin>>m;
    for(i=1;i<=m;i++)
    {
        cin>>x;
        f1=f1+ar[x];
        f2=f2+n-ar[x]+1;
    }
    cout<<f1<<" "<<f2;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define For(i,a,b)  for( i=a;i<b;i++)
#define re(i,a,b)  for( i=a;i>b;i--)
using namespace std;
int main()
{
    int m,n,i,x,f1=0,f2=0;
    vi v;

    cin  >>n;
    int ar[n];
    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
    }
    cin>>m;
    for(i=1;i<=m;i++)
    {
        cin>>x;
        v.pb(x);
    }

        for(i=1;i<=n;i++)
        if(find(all(v),ar[i])!=v.end())
        {
            f1=f1+i;
            f2=f2+n-i+1;
            v.erase(find(all(v),ar[i]));
        }

    cout<<f1<<" "<<f2;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define For(i,a,b)  for( i=a;i<b;i++)
#define re(i,a,b)  for( i=a;i>b;i--)
using namespace std;
int main()
{
    int m,n,i,x,f1=0,f2=0;
    vi v;

    cin  >>n;
    int ar[n];
    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
    }
    cin>>m;
    while(m--)
    {
        cin>>x;
        for(i=1;i<=n;i++)
        if(ar[i]==x)
        {
            f1=f1+i;
            f2=f2+n-i+1;
            break;
        }

    }

    cout<<f1<<" "<<f2;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define For(i,a,b)  for( i=a;i<b;i++)
#define re(i,a,b)  for( i=a;i>b;i--)
using namespace std;
int main()
{
    int m,n,i,x,f1=0,f2=0;
    vi v;

    cin  >>n;
    int ar[n];
    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
    }
    cin>>m;
    for(i=1;i<=m;i++)
    {
        cin>>x;
        v.pb(x);
    }

        for(i=1;i<=n;i++)
        if(find(all(v),ar[i])!=v.end())
        {
            f1=f1+i*(int)count(all(v),ar[i]);
            f2=f2+(n-i+1)*(int)count(all(v),ar[i]);
            v.erase(find(all(v),ar[i]));
        }

    cout<<f1<<" "<<f2;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define For(i,a,b)  for( i=a;i<b;i++)
#define re(i,a,b)  for( i=a;i>b;i--)
using namespace std;
int main()
{
    long long m,n,i,x,f1=0,f2=0,t;
    vector <long long> v;

    cin  >>n;
    long ar[n];
    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
    }
    cin>>m;
    for(i=1;i<=m;i++)
    {
        cin>>x;
        v.pb(x);
    }

        for(i=1;i<=n;i++)
        {
            t=count(all(v),ar[i]);
            if(t)
            {
                f1=f1+i*t;
                f2=f2+(n-i+1)*t;
                auto k=find(all(v),ar[i]);
                v.erase(k,k+t);
            }
        }

    cout<<f1<<" "<<f2;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define For(i,a,b)  for( i=a;i<b;i++)
#define re(i,a,b)  for( i=a;i>b;i--)
using namespace std;
int main()
{
    long long m,n,i,x,f1=0,f2=0,t;
    vi v;

    cin  >>n;
    long long ar[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
    }
    cin>>m;
    for(i=1;i<=m;i++)
    {
        cin>>x;
        v.pb(x);
    }

        for(i=1;i<=n;i++)
        {
            t=count(all(v),ar[i]);
            if(t)
            {
                f1=f1+i*t;
                f2=f2+(n-i+1)*t;
                auto k=find(all(v),ar[i]);
                v.erase(k,k+t);
            }
        }

    cout<<f1<<" "<<f2;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define For(i,a,b)  for( i=a;i<b;i++)
#define re(i,a,b)  for( i=a;i>b;i--)
using namespace std;
int main()
{
    int m,n,i,x,f1=0,f2=0;

    cin  >>n;
    int ar[n];
    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
    }
    cin>>m;
    while(m--)
    {
        cin>>x;
        for(i=1;i<=n;i++)
        if(ar[i]==x)
        {
            f1=f1+i;
            break;
        }
        for(i=n;i>=1;i--)
        if(ar[i]==x)
        {
            f2=f2+n-i+1;
            break;
        }
    }

    cout<<f1<<" "<<f2;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define For(i,a,b)  for( i=a;i<b;i++)
#define re(i,a,b)  for( i=a;i>b;i--)
using namespace std;
int main()
{
    int m,n,i,x,f1=0,f2=0,t;
    vi v;

    cin  >>n;
    int ar[n];
    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
    }
    cin>>m;
    for(i=1;i<=m;i++)
    {
        cin>>x;
        v.pb(x);
    }

        for(i=1;i<=n;i++)
        {

        t=count(all(v),ar[i]);
        if(t)
        {
            f1=f1+i*t;
            f2=f2+(n-i+1)*t;
            auto k=find(all(v),ar[i]);
            v.erase(k,k+t);
        }
        }

    cout<<f1<<" "<<f2;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define For(i,a,b)  for( i=a;i<b;i++)
#define re(i,a,b)  for( i=a;i>b;i--)
using namespace std;
int main()
{
    long long m,n,i,x,f1=0,f2=0,t;
    vi v;

    cin  >>n;
    int ar[n];
    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
    }
    cin>>m;
    for(i=1;i<=m;i++)
    {
        cin>>x;
        v.pb(x);
    }

        for(i=1;i<=n;i++)
        {
            t=count(all(v),ar[i]);
            if(t)
            {
                f1=f1+i*t;
                f2=f2+(n-i+1)*t;
                auto k=find(all(v),ar[i]);
                v.erase(k,k+t);
            }
        }

    cout<<f1<<" "<<f2;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define For(i,a,b)  for( i=a;i<b;i++)
#define re(i,a,b)  for( i=a;i>b;i--)
using namespace std;
int main()
{
    int m,n,i,x,f1=0,f2=0;

    cin  >>n;
    int ar[n];
    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
    }
    cin>>m;
    while(m--)
    {
        cin>>x;
        for(i=1;i<=n;i++)
        if(ar[i]==x)
        {
            f1=f1+i;
            break;
        }
        for(i=n;i>=1;i--)
        if(ar[i]==x)
        {
            f2=f2+i-n+1;
            break;
        }
    }

    cout<<f1<<" "<<f2;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define For(i,a,b)  for( i=a;i<b;i++)
#define re(i,a,b)  for( i=a;i>b;i--)
using namespace std;
int main()
{
    long long m,n,i,x,f1=0,f2=0,t;
    vi v;

    cin  >>n;
    int ar[n];
    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
    }
    cin>>m;
    for(i=1;i<=m;i++)
    {
        cin>>x;
        v.pb(x);
    }

        for(i=1;i<=n;i++)
        {
            t=count(all(v),ar[i]);
            if(t)
            {
                f1=f1+i*t;
                f2=f2+(n-i+1)*t;
                auto k=find(all(v),ar[i]);
                v.erase(k-1,k+t);
            }
        }

    cout<<f1<<" "<<f2;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define For(i,a,b)  for( i=a;i<b;i++)
#define re(i,a,b)  for( i=a;i>b;i--)
using namespace std;
int main()
{
    long long m,n,i,x,f1=0,f2=0,t;
    vi v;

    cin  >>n;
    int ar[n];
    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
    }
    cin>>m;
    for(i=1;i<=m;i++)
    {
        cin>>x;
        v.pb(x);
    }

        for(i=1;i<=n;i++)
        {
            t=count(all(v),ar[i]);
            if(t)
            {
                f1=f1+i*t;
                f2=f2+(n-i+1)*t;
                auto k=find(all(v),ar[i]);
                v.erase(k-1,k+t-1);
            }
        }

    cout<<f1<<" "<<f2;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
   int n,m,k,p,t,l;
   int sum1=0,sum2=0;
   cin >> n;
   int arr[1000];
   int arr2[1000];

   for(int i=1;i<=n;i++)
   {
       cin>> arr[i];
   }

    cin >> m;

    for(int j=0;j<m;j++)
    {
        cin >> arr2[j];
    }

    for(int i=0;i<m;i++)
    {
        for(int k=1;k<=n;k++)
        {
            t++;
            if(arr2[i]==arr[k])
            {
                break;
            }

        }

        for(int p=n;p>=1;p--)
        {
            l++;
            if(arr2[i]==arr[p])
            {
               break;
            }
        }

    }

    cout << t;
    cout << " ";
    cout <<l;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
   int n,m,k,p,t=0,l=0;
   int sum1=0,sum2=0;
   cin >> n;
   int arr[1000];
   int arr2[1000];

   for(int i=1;i<=n;i++)
   {
       cin>> arr[i];
   }

    cin >> m;

    for(int j=0;j<m;j++)
    {
        cin >> arr2[j];
    }

    for(int i=0;i<m;i++)
    {
        for(int k=1;k<=n;k++)
        {
            t++;
            if(arr2[i]==arr[k])
            {
                break;
            }

        }

        for(int p=n;p>=1;p--)
        {
            l++;
            if(arr2[i]==arr[p])
            {
               break;
            }
        }

    }

    cout << t;
    cout << " ";
    cout <<l;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
    int n,m,a,b,sum1=0,sum2=0;
    cin >> n;
    int arr[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        arr[a]=i;
    }
     cin >>m;
    for(int i=0;i<m;i++)
    {
        cin>>b;
         sum1+=arr[b];
         sum2+=n-arr[b]+1;
    }

    cout << sum1;
    cout <<" ";
    cout <<sum2;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
    ll n,m,a,b,sum1=0,sum2=0;
    cin >> n;
    int arr[n+1];
    for(int i=1;i<n;i++)
    {
        cin>>a;
        arr[a]=i;
    }
     cin >>m;
    for(int i=0;i<m;i++)
    {
        cin>>b;
         sum1+=arr[b];
         sum2+=n-arr[b]+1;
    }

    cout << sum1;
    cout <<" ";
    cout <<sum2;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
    int n,m,a,b,sum1=0,sum2=0;
    int arr[n+1];
    for(int i=1;i<n;i++)
    {
        cin>>a;
        arr[a]=i;
    }

    for(int i=0;i<m;i++)
    {
        cin>>b;
         sum1+=arr[b];
         sum2+=n-arr[b]+1;
    }

    cout << sum1;
    cout <<" ";
    cout <<sum2;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
    int n,m,a,b,sum1=0,sum2=0;
    cin >> n;
    int arr[n+1];
    for(int i=1;i<n;i++)
    {
        cin>>a;
        arr[a]=i;
    }
     cin >>m;
    for(int i=0;i<m;i++)
    {
        cin>>b;
         sum1+=arr[b];
         sum2+=n-arr[b]+1;
    }

    cout << sum1;
    cout <<" ";
    cout <<sum2;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
    int n,m,a,b,sum1=0,sum2=0;
    int arr[n+1];
    for(int i=1;i<n;i++)
    {
        cin>>a;
        arr[a]=i;
    }
     cin >>m;
    for(int i=0;i<m;i++)
    {
        cin>>b;
         sum1+=arr[b];
         sum2+=n-arr[b]+1;
    }

    cout << sum1;
    cout <<" ";
    cout <<sum2;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
   int n,m,k,p;
   int sum1=0,sum2=0;
   cin >> n;
   int arr[n];

   for(int i=1;i<=n;i++)
   {
       cin>> arr[i];
   }

    cin >> m;

    int arr2[m];

    for(int j=0;j<m;j++)
    {
        cin >> arr2[j];
    }

    for(int i=0;i<m;i++)
    {
        for(int k=1;k<=n;k++)
        {
            if(arr2[i]==arr[k])
            {
                sum1+=k;
            }

        }

        for(int p=n;p>=1;p--)
        {
            if(arr2[i]==arr[p])
            {
                sum2+=p;
            }
        }

    }

    cout << sum1;
    cout << " ";
    cout <<sum2;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
    ll n,m,a,b,sum1=0,sum2=0;
    cin >> n;
    int arr[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        arr[a]=i;
    }
     cin >>m;
    for(int i=0;i<m;i++)
    {
        cin>>b;
         sum1+=arr[b];
         sum2+=n-arr[b]+1;
    }

    cout << sum1;
    cout <<" ";
    cout <<sum2;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
   int n,m,k,p;
   int sum1=0,sum2=0;
   cin >> n;
   int arr[1000];
   int arr2[1000];

   for(int i=1;i<=n;i++)
   {
       cin>> arr[i];
   }

    cin >> m;

    for(int j=0;j<m;j++)
    {
        cin >> arr2[j];
    }

    for(int i=0;i<m;i++)
    {
        for(int k=1;k<=n;k++)
        {
            if(arr2[i]==arr[k])
            {
                sum1+=k;
            }

        }

        for(int p=n;p>=1;p--)
        {
            if(arr2[i]==arr[p])
            {
                sum2+=p;
            }
        }

    }

    cout << sum1;
    cout << " ";
    cout <<sum2;

}


#include<bits/stdc++.h>
using namespace std;
const int N = int(1e5 + 3);
int main()
{
   long long int n,q,sum=0,count=0;
   cin>>n;
   long long int a[N],b[N],c[N]={0};
   for(long long int i=0;i<n;i++)
   {
   	   cin>>a[i];
   	   c[a[i]]=i+1;
   }
   cin>>q;
   for(long long int i=0 ; i<q ; i++)
   {
   		cin>>b[i];
   		sum = sum + c[b[i]];
   		count = count + n - c[b[i]] + 1;
   }

   cout<<sum<<" "<<count;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,v=0,p=0,pet=0,vas=0;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		//cout<<arr[i];
	}
	int  q;
	cin>>q;
	//cout<<q<<endl;
	while(q--)
	{
		v=0,p=0;
		int a;
		cin>>a;
		//cout<<a;
		for(int i=0;i<n;i++)
		{
			if(arr[i]==a)
			{
			   v++;
               break;
			}
			else
			{
				v++;
			}
		}
		//cout<<v<<endl;
		for(int i=n-1;i>=0;i--)
		{
			if(arr[i]==a)
			{
				p++;
               break;
			}
			else
			{
				p++;
			}
		}
         //cout<<p<<endl;
		vas = vas + v;
		pet= pet+ p;

	}
	cout<<vas<<" "<<pet;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,q,sum=0,count=0;
   cin>>n;
   int a[n],b[n],c[n]={0};
   for(int i=1;i<=n;i++)
   {
   	   cin>>a[i];
   	   c[a[i]]=i;
   }
   cin>>q;
   for(int i=1 ; i<=q ; i++)
   {
   		cin>>b[i];
   		sum = sum + c[b[i]];
   		count = count + n - c[b[i]] + 1;
   }

   cout<<sum<<" "<<count;
}


#include<bits/stdc++.h>
using namespace std;
const int N = int(1e5 + 3);
int main()
{
   long long int n,q,sum=0,count=0;
   cin>>n;
   long long int a[N],b[N],c[N]={0};
   for(long long int i=1;i<=n;i++)
   {
   	   cin>>a[i];
   	   c[a[i]]=i;
   }
   cin>>q;
   for(long long int i=1 ; i<=q ; i++)
   {
   		cin>>b[i];
   		sum = sum + c[b[i]];
   		count = count + n - c[b[i]] + 1;
   }

   cout<<sum<<" "<<count;
}


#include<bits/stdc++.h>
using namespace std;
const int N = int(1e5 + 3);
int main()
{
	long long int i,j,sum=0,sum2=0,m,q,n;
	int arr[N],pos[N];
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
		pos[arr[i]]=i+1;

	}
    cin>>q;
    for(j=0;j<q;j++)
    {
    	int m;
    	cin>>m;
    	sum = sum + pos[m];
    	sum2= sum2 + n - pos[m] + 1;

    }
    cout<<sum<<" "<<sum2;

}


#include<bits/stdc++.h>
using namespace std;
//const int N = int(1e5 + 3);
int main()
{
   long long int n,q,sum=0,count=0;
   cin>>n;
   long long int a[n],b[n+1000],c[n]={0};
   for(long long int i=0;i<n;i++)
   {
   	   cin>>a[i];
   	   c[a[i]]=i+1;
   }
   cin>>q;
   for(long long int i=0 ; i<q ; i++)
   {
   		cin>>b[i];
   		sum = sum + c[b[i]];
   		count = count + n - c[b[i]] + 1;
   }

   cout<<sum<<" "<<count;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int n,q,sum=0,count=0;
   cin>>n;
   long long int a[n],b[n],c[n]={0};
   for(long long int i=1;i<=n;i++)
   {
   	   cin>>a[i];
   	   c[a[i]]=i;
   }
   cin>>q;
   for(long long int i=1 ; i<=q ; i++)
   {
   		cin>>b[i];
   		sum = sum + c[b[i]];
   		count = count + n - c[b[i]] + 1;
   }

   cout<<sum<<" "<<count;
}


#include<bits/stdc++.h>
using namespace std;
//const int N = int(1e5 + 3);
int main()
{
   long long int n,q,sum=0,count=0;
   cin>>n;
   long long int a[n],b[n],c[n]={0};
   for(long long int i=0;i<n;i++)
   {
   	   cin>>a[i];
   	   c[a[i]]=i+1;
   }
   cin>>q;
   for(long long int i=0 ; i<q ; i++)
   {
   		cin>>b[i];
   		sum = sum + c[b[i]];
   		count = count + n - c[b[i]] + 1;
   }

   cout<<sum<<" "<<count;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int n,q,sum=0,count=0;
   cin>>n;
   long long int a[n],b[n],c[n]={0};
   for(long long int i=1;i<=n;i++)
   {
   	   cin>>a[i];
   	   c[a[i]]=i;
   }
   cin>>q;
   for(int i=1 ; i<=q ; i++)
   {
   		cin>>b[i];
   		sum = sum + c[b[i]];
   		count = count + n - c[b[i]] + 1;
   }

   cout<<sum<<" "<<count;
}


#include<bits/stdc++.h>
using namespace std;
//const int N = int(1e5 + 3);
int main()
{
   long long int n,q,sum=0,count=0;
   cin>>n;
   long long int a[n],b[n+1],c[n]={0};
   for(long long int i=0;i<n;i++)
   {
   	   cin>>a[i];
   	   c[a[i]]=i+1;
   }
   cin>>q;
   for(long long int i=0 ; i<q ; i++)
   {
   		cin>>b[i];
   		sum = sum + c[b[i]];
   		count = count + n - c[b[i]] + 1;
   }

   cout<<sum<<" "<<count;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,v=0,p=0,pet=0,vas=0;
	cin>>n;
	int arr[100005];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		//cout<<arr[i];
	}
	long long int  q;
	cin>>q;
	//cout<<q<<endl;
	while(q--)
	{
		v=0,p=0;
		long long int a;
		cin>>a;
		//cout<<a;
		for(int i=0;i<n;i++)
		{
			if(arr[i]==a)
			{
			   v++;
               break;
			}
			else
			{
				v++;
			}
		}
		//cout<<v<<endl;
		for(long long int i=n-1;i>=0;i--)
		{
			if(arr[i]==a)
			{
				p++;
               break;
			}
			else
			{
				p++;
			}
		}
         //cout<<p<<endl;
		vas = vas + v;
		pet= pet+ p;

	}
	cout<<vas<<" "<<pet;
}


#include <bits/stdc++.h>

using namespace std;
const int N = 1e5 + 5;
int x, n, q, cnt1, cnt2, arr[N];

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i){
        scanf("%d", &x);
        arr[x] = i;
    }
    scanf("%d", &q);
    while(q--){
        scanf("%d", &x);
        cnt1 += arr[x];
        cnt2 += n - arr[x] + 1;
    }
    printf("%d %d", cnt1, cnt2);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;
int n, q, qu, l, r, arr[N];

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
        scanf("%d", &arr[i]);
    scanf("%d", &q);
    while(q--){
        bool fv = false,fp = false;
        int j = n + 1, i = 0;
        scanf("%d", &qu);
        while(i <= j){
                j--;
                i++;
            if(arr[i] != qu && arr[j] != qu)
                continue;
            else if(arr[i] == qu && arr[j] == qu)
            {
                fv = true;
                fp = true;
                break;
            }
            else if(arr[i] == qu){
                fv = true;
                break;
            }
            else if(arr[j] == qu){
                fp = true;
                break;
            }
        }
        if(fv && fp){
            l += i;
            r += n - j + 1;
        }
        else if(fv){
            r += (n - j) + (j - i) + 1;
            l += i;
        }
        else{
            r += n - j + 1;
            l += i + (j - i);
        }
        }
    printf("%d %d", l, r);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;
int n, q, res, vasya, petya, arr[N];

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i){
        scanf("%d", &res);
        arr[res] = i;
    }
    scanf("%d", &q);
    for(int i = 1; i <= q; ++i){
        scanf("%d", &res);
        vasya += arr[res];
        petya += n - arr[res] + 1;
    }
    printf("%d %d", vasya, petya);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;
long long n, q, res, vasya, petya, arr[N];

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i){
        scanf("%d", &res);
        arr[res] = i;
    }
    scanf("%d", &q);
    for(int i = 1; i <= q; ++i){
        scanf("%d", &res);
        vasya += arr[res];
        petya += n - arr[res] + 1;
    }
    printf("%d %d", vasya, petya);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;
int n, q, qu, vasya, petya, bas, arr[N];

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
        scanf("%d", &arr[i]);
    scanf("%d", &q);
    bas = q;
    while(q--){
        int j = n;
        int i = 1;
        scanf("%d", &qu);
        while(i < j){
            if(arr[i] != qu){
                vasya++;
                i++;
                }
            if(arr[j] != qu){
                petya++;
                j--;
                }
        }
    }
    printf("%d %d", vasya + bas, petya + bas);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int N = 1e5 + 5;
long long x, n, q, cnt1, cnt2, arr[N];

int main(){
    scanf("%lld", &n);
    for(int i = 1; i <= n; ++i){
        scanf("%lld", &x);
        arr[x] = i;
    }
    scanf("%lld", &q);
    while(q--){
        scanf("%lld", &x);
        cnt1 += arr[x];
        cnt2 += n - arr[x] + 1;
    }
    printf("%lld %lld", cnt1, cnt2);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;
int n, q, qu, l, r, bas, arr[N];

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
        scanf("%d", &arr[i]);
    scanf("%d", &q);
    bas = q;
    while(q--){
        bool fv = false,fp = false;
        int vasya = 0, petya = 0;
        int j = n + 1;
        int i = 0;
        scanf("%d", &qu);
        while(i < j){
                j--;
                i++;
            if(arr[i] != qu && arr[j] != qu)
                continue;
            else if(arr[i] == qu && arr[j] == qu)
            {
                fv = true;
                fp = true;
                break;
            }
            else if(arr[i] == qu){
                fv = true;
                break;
            }
            else if(arr[j] == qu){
                fp = true;
                break;
            }
        }
        if(fv && fp){
            l += i;
            r += n - j + 1;
        }
        else if(fv){
            r += (n - j) + (j - i) + 1;
            l += i;
        }
        else{
            r += n - j + 1;
            l += i + (j - i);
        }
        }

    printf("%d %d", l, r);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;
int n, q, qu, vasya, petya, bas, arr[N];

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
        scanf("%d", &arr[i]);
    scanf("%d", &q);
    bas = q;
    while(q--){
        int j = n;
        int i = 1;
        scanf("%d", &qu);
        for(i = 1; i <= n; ++i)
            if(arr[i] != qu)
                vasya++;
            else if(arr[i] == qu)
                break;
        vasya++;
        petya += n + 1 - i;
        }

    printf("%d %d", vasya, petya);
    return 0;
}


#include<bits\stdc++.h>
using namespace std;
int main()
{
	int n,m,sum=0,q=0;
	long long int count1=0,count2=0;
	cin>>n;
	int a[n],arr[100009];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		arr[a[i]]=i+1;
	}
	cin>>m;
	int b[m];
	for(int j=0;j<m;j++)
	{
		cin>>b[j];
		count1=arr[b[j]]+count1;
		count2=n-arr[b[j]]+count2+1;
	}

	cout<<count1<<" "<<count2;
}


#include<bits\stdc++.h>
using namespace std;
int main()
{
	int n,m,count1=0,count2=0,sum=0,q=0;
	cin>>n;
	int a[n],arr[100000];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		arr[a[i]]=i+1;
	}
	cin>>m;
	int b[m];
	for(int j=0;j<m;j++)
	{
		cin>>b[j];
		count1=arr[b[j]]+count1;
		count2=n-arr[b[j]]+count2+1;
	}

	cout<<count1<<" "<<count2;
}


#include<bits\stdc++.h>
using namespace std;
int main()
{
	int n,m,count1=0,count2=0,sum=0,q=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	cin>>m;
	int b[m];
	for(int j=0;j<m;j++)
	{
		cin>>b[j];
	}
	for(int w=0;w<n;w++)
	{
		count1++;
		if(b[q]==a[w])
		{
			q++;
			w=-1;
			sum=sum+count1;
			count2=n-count1+1+count2;
			count1=0;
			continue;
		}
	}
	cout<<sum<<" "<<count2;
}


#include<bits\stdc++.h>
using namespace std;
int main()
{
	int n,m,count1=0,count2=0,sum=0,q=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	cin>>m;
	int b[m];
	for(int j=0;j<m;j++)
	{
		cin>>b[j];
	}
	for(int w=0;w<n;w++)
	{
		count1++;
		if(b[q]==a[w])
		{
			q++;
			w=0;
			sum=sum+count1;
			count2=n-count1+1+count2;
			count1=0;
			continue;
		}
	}
	cout<<sum<<" "<<count2;
}


#include<bits\stdc++.h>
using namespace std;
int main()
{
	int n,m,sum=0,q=0;
	long long int count1=0;count2=0;
	cin>>n;
	int a[n],arr[100009];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		arr[a[i]]=i+1;
	}
	cin>>m;
	int b[m];
	for(int j=0;j<m;j++)
	{
		cin>>b[j];
		count1=arr[b[j]]+count1;
		count2=n-arr[b[j]]+count2+1;
	}

	cout<<count1<<" "<<count2;
}


#include<bits\stdc++.h>
using namespace std;
int main()
{
	int n,m,count1=0,count2=0,sum=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	cin>>m;
	int b[m];
	for(int j=0;j<m;j++)
	{
		cin>>b[j];
	}
	for(int q=0;q<m;q++)
	{
		count1=0;
		for(int w=0;w<n;w++)
		{
			count1++;
			if(b[q]==a[w])
			{
				break;
			}
		}
		sum=sum+count1;
		count2=n-count1+1+count2;
	}
	cout<<sum<<" "<<count2;
}


#include<bits\stdc++.h>
using namespace std;
int main()
{
	int n,m,count1=0,count2=0,sum=0,q=0;
	cin>>n;
	int a[n],arr[100009];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		arr[a[i]]=i+1;
	}
	cin>>m;
	int b[m];
	for(int j=0;j<m;j++)
	{
		cin>>b[j];
		count1=arr[b[j]]+count1;
		count2=n-arr[b[j]]+count2+1;
	}

	cout<<count1<<" "<<count2;
}


#include<bits\stdc++.h>
using namespace std;
int main()
{
	int n,m,count1=0,count2=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	cin>>m;
	int b[m];
	for(int j=0;j<m;j++)
	{
		cin>>b[j];
	}
	for(int q=0;q<m;q++)
	{
		for(int w=0;w<n;w++)
		{
			count1++;
			if(b[q]==a[w])
			{
				break;
			}
		}
		for(int z=n-1;z>=0;z--)
		{
			count2++;
			if(b[q]==a[z])
			{
				break;
			}
		}
	}
	cout<<count1<<" "<<count2;
}


#include<bits\stdc++.h>
using namespace std;
int main()
{
	int n,m,count1=0,count2=0,sum=0,q=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	cin>>m;
	int b[m];
	for(int j=0;j<m;j++)
	{
		cin>>b[j];
	}/*
	for(int w=0;w<n;w++)
	{
		count1++;
		if(b[q]==a[w])
		{
			q++;
			w=-1;
			sum=sum+count1;
			count2=n-count1+1+count2;
			count1=0;
		}
	}*/
	cout<<sum<<" "<<count2;
}


#include<iostream>
using namespace std;
 int n , m , *a , *b , x=0 , y=0;
int main()
{
 cin>>n;
 a=new int[n];
 for(int i=0; i<n; i++)cin>>a[i];

  cin>>m;
 b=new int[m];

 for(int i=0; i<m; i++){
     cin>>b[i];
     for(int j=0; j<n; j++){
         if(b[i]==a[j]) x+=(j+1);
     }
    for(int j=n-1; j>=0; j--){
         if(b[i]==a[j]) y+=(n-j);
     }
 }

 cout<<x<<" "<<y;
}


#include<iostream>
using namespace std;
long long m , n , b , x=0 , y=0;

int main()
{
 cin>>n;
 int* a=new int[n];
 for(int i=0; i<n; i++){
     cin>>b;
     a[b]=i;
 };
  cin>>m;
 for(int i=0; i<m; i++){
     cin>>b;
     x+=(a[b]+1);
     y+=(n-a[b]);
 }

 cout<<x<<" "<<y;
}


#include<iostream>
using namespace std;
 long long n , m , *a , *b , x=0 , y=0;
int main()
{
 cin>>n;
 a=new long long[n];
 for(int i=0; i<n; i++)cin>>a[i];

  cin>>m;
 b=new long long[m];
  for(int i=0; i<m; i++)cin>>b[i];

 for(int i=0; i<m; i++){
     for(int j=0; j<n; j++){
         if(b[i]==a[j]){ x+=(j+1); y+=(n-j); break;}
     }
 }

 cout<<x<<" "<<y;
}


#include<iostream>
using namespace std;
 int n , m , *a , *b ;
 long long x=0 , y=0;
int main()
{
 cin>>n;
 a=new int[n];
 for(int i=0; i<n; i++)cin>>a[i];

  cin>>m;
 b=new int[m];
  for(int i=0; i<m; i++)cin>>b[i];

 for(int i=0; i<m; i++){
     for(int j=0; j<n; j++){
         if(b[i]==a[j]){ x+=(j+1); y+=(n-j); break;}
     }
 }

 cout<<x<<" "<<y;
}


#include<iostream>
using namespace std;
 int n , m , *a , *b;
 long long x=0 , y=0;
int main()
{
 cin>>n;
 a=new int[n];
 for(int i=0; i<n; i++)cin>>a[i];

  cin>>m;
 b=new int[m];
 for(int i=0; i<m; i++)cin>>b[i];

 for(int i=0; i<m; i++){
     for(int j=0; j<n; j++){
         if(b[i]==a[j]) x+=(j+1);
     }
 }

  for(int i=0; i<m; i++){
     for(int j=n-1; j>=0; j--){
         if(b[i]==a[j]) y+=(n-j);
     }
 }

 cout<<x<<" "<<y;
}


#include<iostream>
using namespace std;
 int n , m , *a , *b ;
 long long x=0 , y=0;
int main()
{
 cin>>n;
 a=new int[n];
 for(int i=0; i<n; i++)cin>>a[i];

  cin>>m;
 b=new int[m];

 for(int i=0; i<m; i++){
     cin>>b[i];
     for(int j=0; j<n; j++){
         if(b[i]==a[j]){ x+=(j+1); y+=(n-j);}
     }
 }

 cout<<x<<" "<<y;
}


#include<iostream>
using namespace std;
 int n , m , *a , *b ;
 long long x=0 , y=0;
int main()
{
 cin>>n;
 a=new int[n];
 for(int i=0; i<n; i++)cin>>a[i];

  cin>>m;
 b=new int[m];

 for(int i=0; i<m; i++){
     cin>>b[i];
     for(int j=0; j<n; j++){
         if(b[i]==a[j]){ x+=(j+1); y+=(n-j); break;}
     }
 }

 cout<<x<<" "<<y;
}


#include<iostream>
using namespace std;
 int n , m , *a , *b , x=0 , y=0;
int main()
{
 cin>>n;
 a=new int[n];
 for(int i=0; i<n; i++)cin>>a[i];

  cin>>m;
 b=new int[m];

 for(int i=0; i<m; i++){
     cin>>b[i];
     for(int j=0; j<n; j++){
         if(b[i]==a[j]){ x+=(j+1); y+=(n-j);}
     }
 }

 cout<<x<<" "<<y;
}


#include<iostream>
using namespace std;
 long long n , m , *a , b , x=0 , y=0;
int main()
{
 cin>>n;
 a=new long long[n];
 for(int i=0; i<n; i++)cin>>a[i];
  cin>>m;
 for(int i=0; i<m; i++){
     cin>>b;
     for(int j=0; j<n; j++){
         if(b==a[j]){ x+=(j+1); y+=(n-j); break;}
     }
 }

 cout<<x<<" "<<y;
}


#include<iostream>
using namespace std;
 int n , m , *a , *b , x=0 , y=0;
int main()
{
 cin>>n;
 a=new int[n];
 for(int i=0; i<n; i++)cin>>a[i];

  cin>>m;
 b=new int[m];
 for(int i=0; i<m; i++)cin>>b[i];

 for(int i=0; i<m; i++){
     for(int j=0; j<n; j++){
         if(b[i]==a[j]) x+=(j+1);
     }
 }

  for(int i=0; i<m; i++){
     for(int j=n-1; j>=0; j--){
         if(b[i]==a[j]) y+=(n-j);
     }
 }

 cout<<x<<" "<<y;
}


#include<iostream>

using namespace std;

int main()  {
    long n;
    long long vasya = 0, petya = 0;
    cin >> n;
    long a[n], c[n];
    for(long i = 0;i<n;i++)
        cin >> a[i];
    for(long i = 0;i<n;i++)
        c[a[i]-1] = i;
    long m;
    cin >> m;
    long b[m];
    for(long i=0;i<m;i++)    {
        cin >> b[i];
        vasya += c[b[i]-1] + 1;
        petya += n-c[b[i]-1];
    }
    cout << vasya << " "<< petya;
    return 0;
}


#include<iostream>

using namespace std;

int main()  {
    unsigned int n, vasya = 0, petya = 0;
    cin >> n;
    unsigned int a[n], c[n];
    for(int i = 0;i<n;i++)
        cin >> a[i];
    for(int i = 0;i<n;i++)
        c[a[i]-1] = i;
    unsigned int m;
    cin >> m;
    unsigned int b[m];
    for(int i=0;i<m;i++)    {
        cin >> b[i];
        vasya += c[b[i]-1] + 1;
        petya += n-c[b[i]-1];
    }
    cout << vasya << " "<< petya;
    return 0;
}


#include<iostream>

using namespace std;

int main()  {
    int n, vasya = 0, petya = 0;
    cin >> n;
    int a[n];
    for(int i = 0;i<n;i++)
        cin >> a[i];
    int m;
    cin >> m;
    int b[m];
    for(int i=0;i<m;i++)
        cin >> b[i];
    for(int i=0;i<m;i++)    {
        for(int j = 0;j<n;j++)  {
            if(b[i] == a[j])    {
                vasya+=j+1;
                petya += n-j;
            }
            else if(b[i] == a[n-j-1])   {
                vasya += n-j;
                petya += j+1;
            }
        }
    }
    cout << vasya << " "<< petya;
    return 0;
}


#include<iostream>

using namespace std;

int main()  {
    int n, vasya = 0, petya = 0;
    cin >> n;
    int a[n];
    for(int i = 0;i<n;i++)
        cin >> a[i];
    int m;
    cin >> m;
    int b[m];
    for(int i=0;i<m;i++)
        cin >> b[i];
    for(int i=0;i<m;i++)    {
        for(int j = 0;j<n/2;j++)  {
            if(b[i] == a[j])    {
                vasya+=j+1;
                petya += n-j;
            }
            else if(b[i] == a[n-j-1])   {
                vasya += n-j;
                petya += j+1;
            }
        }
    }
    cout << vasya << " "<< petya;
    return 0;
}


#include<iostream>

using namespace std;

int main()  {
    int n, vasya = 0, petya = 0;
    cin >> n;
    int a[n];
    for(int i = 0;i<n;i++)
        cin >> a[i];
    int m;
    cin >> m;
    int b[m];
    for(int i=0;i<m;i++)
        cin >> b[i];
    for(int i=0;i<m;i++)    {
        for(int j = 0;j<n;j++)  {
            if(b[i] == a[j])    {
                vasya+=j+1;
                petya += n-j;
            }
        }
    }
    cout << vasya << " "<< petya;
    return 0;
}


#include<iostream>

using namespace std;

int main()  {
    int n, vasya = 0, petya = 0, n1;
    cin >> n;
    int a[n];
    for(int i = 0;i<n;i++)
        cin >> a[i];
    int m;
    cin >> m;
    int b[m];
    for(int i=0;i<m;i++)
        cin >> b[i];
    if(n%2!=0)
        n1 = n/2+1;
    else
        n1 = n/2;
    for(int i=0;i<m;i++)    {
        for(int j = 0;j<n1;j++)  {
            if(b[i] == a[j])    {
                vasya+=j+1;
                petya += n-j;
            }
            else if(b[i] == a[n-j-1])   {
                vasya += n-j;
                petya += j+1;
            }
        }
    }
    cout << vasya << " "<< petya;
    return 0;
}


#include<iostream>

using namespace std;

int main()  {
    int n, vasya = 0, petya = 0;
    cin >> n;
    int a[n], c[n];
    for(int i = 0;i<n;i++)
        cin >> a[i];
    for(int i = 0;i<n;i++)
        c[a[i]-1] = i;
    int m;
    cin >> m;
    int b[m];
    for(int i=0;i<m;i++)    {
        cin >> b[i];
        vasya += c[b[i]-1] + 1;
        petya += n-c[b[i]-1];
    }
    cout << vasya << " "<< petya;
    return 0;
}


#include<iostream>

using namespace std;

int main()  {
    long n, vasya = 0, petya = 0;
    cin >> n;
    long a[n], c[n];
    for(long i = 0;i<n;i++)
        cin >> a[i];
    for(long i = 0;i<n;i++)
        c[a[i]-1] = i;
    long m;
    cin >> m;
    long b[m];
    for(long i=0;i<m;i++)    {
        cin >> b[i];
        vasya += c[b[i]-1] + 1;
        petya += n-c[b[i]-1];
    }
    cout << vasya << " "<< petya;
    return 0;
}


#include<iostream>

using namespace std;

int main()  {
    int n, vasya = 0, petya = 0;
    cin >> n;
    int a[n];
    for(int i = 0;i<n;i++)
        cin >> a[i];
    int m;
    cin >> m;
    int b[m];
    for(int i=0;i<m;i++)
        cin >> b[i];
    for(int i=0;i<m;i++)    {
        for(int j = 0;j<=n/2;j++)  {
            if(b[i] == a[j])    {
                vasya+=j+1;
                petya += n-j;
            }
            else if(b[i] == a[n-j-1])   {
                vasya += n-j;
                petya += j+1;
            }
        }
    }
    cout << vasya << " "<< petya;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<int>check(100005);
int main(){
    int n,q;
    cin>>n;
    for(int i=1;i<=n;i++){
        int t;
        cin>>t;
        check(t)=i;
    }
    cin>>q;
    ll vs=0, ps=0;
    for(int i=0;i<q;i++){
        int t;
        cin>>t;
        vs+=check(t);
        ps+=(n-check(t));
    }
    cout<<vs<<" "<<ps;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n, q, t;
    ll ps=0, vs=0;
    bool vStatus=true, pStatus=true;
    cin>>n;
    vector<int>arr(n);
    for(int i=0;i<n;i++)cin>>arr[i];
    cin>>q;
    vector<int>que(q);
    for(int i=0;i<q;i++){
        cin>>t;
        que[i]=t;
    }
    for(int i=0;i<q;i++){
        t=que[i];
        for(int j=0;j<n;j++){
            if(vStatus)vs++;
            if(pStatus)ps++;
            if(!vStatus && !pStatus)break;
            if(arr[j]==t)vStatus=false;
            if(arr[n-j-1]==t)pStatus=false;
        }
    }
    cout<<vs<<" "<<ps;
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<int>check(100005);
int main(){
    int n,q;
    cin>>n;
    for(int i=1;i<=n;i++){
        int t;
        cin>>t;
        check(t)=i;
    }
    cin>>q;
    ll vs=0, ps=0;
    for(int i=0;i<q;i++){
        int t;
        cin>>t;
        vs+=check[t];
        ps+=(n-check[t]);
    }
    cout<<vs<<" "<<ps;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n, q, vs=0, ps=0, t;
    cin>>n;
    vector<ll>arr(n);
    for(ll i=0;i<n;i++)cin>>arr[i];
    cin>>q;
    vector<ll>que(q);
    for(ll i=0;i<q;i++){
        cin>>t;
        que[i]=t;
        for(ll j=0;j<n;j++){
            vs++;
            if(arr[j]==t){
                break;
            }
        }
        for(ll j=n-1;j>=0;j--){
            ps++;
            if(arr[j]==t){
                break;
            }
        }
    }
    cout<<vs<<" "<<ps;
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n, q, vs=0, ps=0, t;
    cin>>n;
    vector<ll>arr(n);
    for(ll i=0;i<n;i++)cin>>arr[i];
    cin>>q;
    vector<ll>que(q);
    for(ll i=0;i<q;i++){
        cin>>t;
        que[i]=t;
    }
    for(ll i=0;i<q;i++){
        t=que[i];
        for(ll j=0;j<n;j++){
            vs++;
            if(arr[j]==t){
                break;
            }
        }
        for(ll j=n-1;j>=0;j--){
            ps++;
            if(arr[j]==t){
                break;
            }
        }
    }
    cout<<vs<<" "<<ps;
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n, q, t;
    ll ps=0, vs=0;
    cin>>n;
    vector<int>arr(n);
    for(int i=0;i<n;i++)cin>>arr[i];
    cin>>q;
    vector<int>que(q);
    for(int i=0;i<q;i++){
        cin>>t;
        que[i]=t;
    }
    for(int i=0;i<q;i++){
        bool vStatus=true, pStatus=true;
        t=que[i];
        for(int j=0;j<n;j++){
            if(vStatus)vs++;
            if(pStatus)ps++;
            if(!vStatus && !pStatus)break;
            if(arr[j]==t)vStatus=false;
            if(arr[n-j-1]==t)pStatus=false;
        }
    }
    cout<<vs<<" "<<ps;
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<int>check(100005);
int main(){
    int n,q;
    cin>>n;
    for(int i=1;i<=n;i++){
        int t;
        cin>>t;
        check[t]=i;
    }
    cin>>q;
    ll vs=0, ps=0;
    for(int i=0;i<q;i++){
        int t;
        cin>>t;
        vs+=check[t];
        ps+=(n-check[t]);
    }
    cout<<vs<<" "<<ps;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<int>check(100005);
int main(){
    int n,q;
    cin>>n;
    for(int i=1;i<=n;i++){
        int t;
        cin>>t;
        check[t]=i;
    }
    cin>>q;
    ll vs=0, ps=0;
    for(int i=0;i<q;i++){
        int t;
        cin>>t;
        vs+=check[t];
        ps+=(n-check[t]+1);
    }
    cout<<vs<<" "<<ps;
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n=0,q=0;
    vector<int> v1,q1;
    cin >> n;
    for (int i=0; i<n; i++)
    {
        int temp=0;
        cin >> temp;
        v1.push_back(temp);
    }

    cin >> q;

    int vasyan =0;
    int petyan = 0;
    for (int i=0; i<q; i++)
    {
        int q1 = 0;
        cin >> q1;
        for (int j=0; j<n; j++)
        {

            if(q1!= v1[j])
                vasyan++;
            else
            {   vasyan++;
                break;
            }
        }
    }

    petyan = (q*(n+1)) - vasyan;

    cout << vasyan << " "<<petyan <<endl;
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n=0,q=0;
    vector<int> v1,q1;
    cin >> n;
    for (int i=0; i<n; i++)
    {
        int temp=0;
        cin >> temp;
        v1.push_back(temp);
    }

    cin >> q;

    for (int i=0; i<q; i++)
    {
        int temp=0;
        cin >> temp;
        q1.push_back(temp);
    }

    int vasyan =0;
    int petyan = 0;
    for (int i=0; i<q; i++)
    {
        for (int j=0; j<n; j++)
        {

            if(q1[i]!= v1[j])
                vasyan++;
            else
            {   vasyan++;
                break;
            }
        }
    }

    petyan = (q*(n+1)) - vasyan;

    cout << vasyan << " "<<petyan <<endl;
    return 0;
}


#include <iostream>
#include <map>
using namespace std;

int main()
{
    long long n=0,q=0;
    cin >> n;
    map<int, int> v1;

    for (int i=0; i<n; i++)
    {
        int temp=0;
        cin >> temp;
        v1.insert(pair<long long, long long >(temp,i));
    }

    cin >> q;

    long long vasyan =0;
    long long petyan = 0;
    for (long long i=0; i<q; i++)
    {
        long long q1 = 0;
        cin >> q1;

        vasyan += (v1.find(q1)->second+1);
    }

    petyan = (q*(n+1)) - vasyan;

    cout << vasyan << " "<<petyan <<endl;
    return 0;
}


#include <iostream>
#include <map>
using namespace std;

int main()
{
    int n=0,q=0;
    cin >> n;
    map<int, int> v1;

    for (int i=0; i<n; i++)
    {
        int temp=0;
        cin >> temp;
        v1.insert(pair<int, int >(temp,i));
    }

    cin >> q;

    int vasyan =0;
    int petyan = 0;
    for (int i=0; i<q; i++)
    {
        int q1 = 0;
        cin >> q1;

        vasyan += (v1.find(q1)->second+1);
    }

    petyan = (q*(n+1)) - vasyan;

    cout << vasyan << " "<<petyan <<endl;
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n=0,q=0;
    vector<int> v1,q1;
    cin >> n;
    for (int i=0; i<n; i++)
    {
        int temp=0;
        cin >> temp;
        v1.push_back(temp);
    }

    cin >> q;

    for (int i=0; i<q; i++)
    {
        int temp=0;
        cin >> temp;
        q1.push_back(temp);
    }

    int size = v1.size();
    int vasyan =0;
    int petyan = 0;
    for (int i=0; i<q; i++)
    {
        for (int j=0; j<size; j++)
        {

            if(q1[i]!= v1[j])
                vasyan++;
            else
            {   vasyan++;
                break;
            }
        }
    }

    for (int i=0; i<q; i++)
    {
        for (int j=size-1; j>=0; j--)
        {

            if(q1[i]!= v1[j])
                petyan++;
            else
            {   petyan++;
                break;
            }
        }
    }
    cout << vasyan << " "<<petyan <<endl;
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
    int n=0,q=0;
    cin >> n;
    int* v1 = new int[n];

    for (int i=0; i<n; i++)
    {
        int temp=0;
        cin >> temp;
        v1[i] = temp;
    }

    cin >> q;

    int vasyan =0;
    int petyan = 0;
    for (int i=0; i<q; i++)
    {
        int q1 = 0;
        cin >> q1;
        for (int j=0; j<n; j++)
        {

            if(q1!= v1[j])
                vasyan++;
            else
            {   vasyan++;
                break;
            }
        }
    }

    petyan = (q*(n+1)) - vasyan;

    cout << vasyan << " "<<petyan <<endl;
    return 0;
}


#include <iostream>
#include <map>
using namespace std;

int main()
{
    int n=0,q=0;
    cin >> n;
    map<int, int> v1;

    for (int i=0; i<n; i++)
    {
        int temp=0;
        cin >> temp;
        v1.insert(pair<int, int >(temp,i));
    }

    cin >> q;

    long long vasyan =0;
    long long petyan = 0;
    for (int i=0; i<q; i++)
    {
        int q1 = 0;
        cin >> q1;

        vasyan += (v1.find(q1)->second+1);
    }

    petyan = (q*(n+1)) - vasyan;

    cout << vasyan << " "<<petyan <<endl;
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n=0,q=0;
    vector<int> v1,q1;
    cin >> n;
    for (int i=0; i<n; i++)
    {
        int temp=0;
        cin >> temp;
        v1.push_back(temp);
    }

    cin >> q;

    for (int i=0; i<q; i++)
    {
        int temp=0;
        cin >> temp;
        q1.push_back(temp);
    }

    int vasyan =0;
    int petyan = 0;
    for (int i=0; i<q; i++)
    {
        for (int j=0; j<n; j++)
        {

            if(q1[i]!= v1[j])
                vasyan++;
            else
            {   vasyan++;
                break;
            }
        }
    }

    for (int i=0; i<q; i++)
    {
        for (int j=n-1; j>=0; j--)
        {

            if(q1[i]!= v1[j])
                petyan++;
            else
            {   petyan++;
                break;
            }
        }
    }
    cout << vasyan << " "<<petyan <<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
	int n,m,c=0,d=0,x=0,y=0;
 	cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
        cin >> m;
                int b[m];
    for (int i = 0; i < m; ++i)
    {
        cin >> b[i];
    }
    for (int i = 0; i < m; ++i)
    {
         for (int j = 0; j < n; ++j){
            if(b[i]==a[j]){
                c=j+1;
                d=n-j;
                break;
            }
         }
         x=x+c;
         y=y+d;
    }
    printf("%d ",x);
    cout << y ;
    return 0;
}


#include<bits/stdc++.h>
#include<map>
#include<string>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep1(i,a,b) for(ll i=a;i<= b;i++)
#define PI          3.14159
#define MAX         1000001
#define left (2*i+1)
#define right (2*i+2)
#define fast_io ios_base::sync_with_stdio(false);  cin.tie(0);  cout.tie(0);
using namespace std;
int main()
{
  ll n;
  cin >> n;
  ll ans[33];
  memset(ans,0,sizeof(ans));
  for(ll i = 0;  i < n; i++)
  {
    ll num;
    cin >> num;
    ll tmp = 0;
    for(ll j = 0; j <= 31; j++)
    {
      if(num & 1 << j)
      {
        tmp++;
      }
    }
    ans[tmp]++;
  }
  ll cnt = 0;
  rep(i,0,33)
  {
    cnt += ans[i]*(ans[i] - 1)/2;
  }
  cout << cnt << endl;
  return 0;
}


#include<bits/stdc++.h>
#include<map>
#include<string>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep1(i,a,b) for(ll i=a;i<= b;i++)
#define PI          3.14159
#define MAX         1000001
#define left (2*i+1)
#define right (2*i+2)
#define fast_io ios_base::sync_with_stdio(false);  cin.tie(0);  cout.tie(0);
using namespace std;
ll dp[778][778];
void comb()
{
  dp[0][0] = 1;
  for(ll i = 1; i <= 777;  i++)
  {
    for(ll j = 0; j <= 777; j++)
    {
      if(j > i)
      {
        dp[i][j] = 0;
        continue;
      }
      dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
    }
  }
  return ;
}
int main()
{
  ll n;
  cin >> n;
  comb();
  ll odd = 0;
  ll even = 0;
  rep(i,0,n)
  {
    ll num;
    cin >> num;
    if(num & 1 && num != 1)
    {
      odd++;
    }
    else
    {
      even++;
    }
  }
  ll ans = dp[odd][2] + dp[even][2];
  cout << ans;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,ii> iii;
typedef pair<double, ii> dii;
typedef long long ll;
const ll INF = 1e18;
const double EPS = 1e-9;
#define LSOne(S) (S & (-S))
int mods(int a, int b) { return (b + (a%b)) % b; }

int countBits(int x) {
    int on = 0;
    while (x) { on++; x &= x-1; }
    return on;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n, a, ans = 0, A[35] = {};

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a;
        A[countBits(a)]++;
    }

    for (int i = 0; i <= 30; i++)
        ans+=(A[i]*(A[i]-1)/2);

    cout << ans << '\n';

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,ii> iii;
typedef pair<double, ii> dii;
typedef long long ll;
const ll INF = 1e18;
const double EPS = 1e-9;
#define LSOne(S) (S & (-S))
int mods(int a, int b) { return (b + (a%b)) % b; }

int countBits(int x) {
    int on = 0;
    while (x) { on++; x &= x-1; }
    return on;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n, a;
    ll ans = 0, A[35] = {};

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a;
        A[countBits(a)]++;
    }

    for (int i = 0; i <= 30; i++)
        ans+=(A[i]*(A[i]-1)/2);

    cout << ans << '\n';

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,ii> iii;
typedef pair<double, ii> dii;
typedef long long ll;
const ll INF = 1e18;
const double EPS = 1e-9;
#define LSOne(S) (S & (-S))
int mods(int a, int b) { return (b + (a%b)) % b; }

int countBits(int x) {
    int on = 0;
    while (x) { on++; x &= x-1; }
    return on;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n, a, A[35] = {};
    ll ans = 0;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a;
        A[countBits(a)]++;
    }

    for (int i = 0; i <= 30; i++)
        ans+=(A[i]*(A[i]-1)/2);

    cout << ans << '\n';

    return 0;
}


#define CF
#include <cstddef>
#ifdef CF
#include <iostream>
#else
#include <fstream>
#endif
#include <cmath>

int f( int x )
{
	if( x == 0 )
		return 0;
	if( x % 2 == 0 )
		return f( x / 2 );
	return f( x / 2 ) + 1;
}

int main()
{
#ifdef CF
	std::istream& is = std::cin;
	std::ostream& os = std::cout;
#else
	std::ifstream is( "input.txt" );
	std::ofstream os( "output.txt" );
#endif // CF

	int n, i, a;
	is >> n;

	//int * as = new int[n+1];
	int maxf = ceil( log( n + 1 ) / log( 2.0 ) );
	int * g = new int[ maxf + 1 ];
	for( i = 0; i <= maxf; i++ )
		g[i] = 0;

	for( i = 1; i <= n; i++ )
	{
		is >> a; //as[i];
		g[ f( a /*as[i]*/ ) ]++;
	}

	int s = 0;
	for( i = 0; i <= maxf; i++ )
		s += ( g[i]*g[i] - g[i] ) / 2;

	os << s;
}


#define CF
#include <cstddef>
#ifdef CF
#include <iostream>
#else
#include <fstream>
#endif
#include <cmath>

int f( int x )
{
	if( x == 0 )
		return 0;
	if( x % 2 == 0 )
		return f( x / 2 );
	return f( x / 2 ) + 1;
}

int main()
{
#ifdef CF
	std::istream& is = std::cin;
	std::ostream& os = std::cout;
#else
	std::ifstream is( "input.txt" );
	std::ofstream os( "output.txt" );
#endif // CF

	int n, i, a;
	is >> n;

	//int * as = new int[n+1];
	int maxf = 30;
	long long * g = new long long[ maxf + 1 ];
	for( i = 0; i <= maxf; i++ )
		g[i] = 0;

	for( i = 1; i <= n; i++ )
	{
		is >> a; //as[i];
		g[ f( a /*as[i]*/ ) ]++;
	}

	long long s = 0;
	for( i = 0; i <= maxf; i++ )
		s += ( g[i]*g[i] - g[i] ) / 2;

	os << s;
}


#define CF
#include <cstddef>
#ifdef CF
#include <iostream>
#else
#include <fstream>
#endif
#include <cmath>

int f( int x )
{
	if( x == 0 )
		return 0;
	if( x % 2 == 0 )
		return f( x / 2 );
	return f( x / 2 ) + 1;
}

int main()
{
#ifdef CF
	std::istream& is = std::cin;
	std::ostream& os = std::cout;
#else
	std::ifstream is( "input.txt" );
	std::ofstream os( "output.txt" );
#endif // CF

	int n, i, a;
	is >> n;

	//int * as = new int[n+1];
	int maxf = 30;
	int * g = new int[ maxf + 1 ];
	for( i = 0; i <= maxf; i++ )
		g[i] = 0;

	for( i = 1; i <= n; i++ )
	{
		is >> a; //as[i];
		g[ f( a /*as[i]*/ ) ]++;
	}

	int s = 0;
	for( i = 0; i <= maxf; i++ )
		s += ( g[i]*g[i] - g[i] ) / 2;

	os << s;
}


#include <bits/stdc++.h>
using namespace std;
long long f(long long a)
{
       if(a==0)
	   return 0;
	   else if(a%2==0)
	   return f(a/2);
	   else
	   return f((a-1)/2) + 1;
}
int main()
{
	long long n,r=0;   cin>>n;
	map<long long,int> p,m;
	vector<long long> v;
	for(long long i=1;i<=n;++i)
	{
		long long x;   cin>>x;
		p[f(x)]++;
	//	cout<<f(x)<<" "<<p[f(x)]<<endl;
		if(m[f(x)]<1)
		m[f(x)]++,v.push_back(f(x));
	}
	for(int i=0;i<v.size();++i)
	{
	//	cout<<v[i]<<" "<<p[v[i]]<<endl;
		r = r + ( p[v[i]] * (p[v[i]] - 1))/2;
	//	cout<<r<<endl;
	}
	cout<<r<<endl;
}


#include <bits/stdc++.h>
using namespace std;
long long f(long long a)
{
       if(a==0)
	   return 0;
	   else if(a%2==0)
	   return f(a/2);
	   else
	   return f((a-1)/2) + 1;
}
int main()
{
	long long n,r=0;   cin>>n;
	map<long long,long long> p,m;
	vector<long long> v;
	for(long long i=1;i<=n;++i)
	{
		long long x;   cin>>x;
		p[f(x)]++;
	//	cout<<f(x)<<" "<<p[f(x)]<<endl;
		if(m[f(x)]<1)
		m[f(x)]++,v.push_back(f(x));
	}
	for(int i=0;i<v.size();++i)
	{
	//	cout<<v[i]<<" "<<p[v[i]]<<endl;
		r = r + ( p[v[i]] * (p[v[i]] - 1))/2;
	//	cout<<r<<endl;
	}
	cout<<r<<endl;
}


#include <bits/stdc++.h>
using namespace std;
long long binomialCoeff(long long n, long long k)
{
	if(n<k)
	return 0;
    long long res = 1;

    // Since C(n, k) = C(n, n-k)
    if ( k > n - k )
        k = n - k;

    // Calculate value of [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]
    for (long long i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
int main()
{
	map<long long,int> m;
	m[1] = 1;
	for(long long i=2;i<=1000000000;++i)
	{
		if(m[i]<1 && i%2==0 && m[i/2]>0)
		{
			m[i] = m[i/2];
			if(m[i+1]<1)
			m[i+1] = i+1;
			for(long long j=2*i;j<=1000000000;j=j*2)
			{
				m[j] = m[i];
				m[j+1] = m[i+1];
			}
		}
		else if(m[i]<1)
		{
		    m[i] = i;
			if(m[i+1]<1)
			m[i+1] = i+1;
			for(int j=2*i;j<=1000000000;j=j*2)
			{
				m[j] = m[i];
				m[j+1] = m[i+1];
			}
		}
	}
	long long n,r=0;   cin>>n;
	map<long long,int> p;
	for(long long i=1;i<=n;++i)
	{
		long long x;   cin>>x;
		p[m[x]]++;
	//	cout<<m[x]<<" ";
	}
//	cout<<endl;
	for(long long i=1;i<=1000000000;++i)
	{
		if(p[i]>1)
		r = r + binomialCoeff(p[i],2);
	}
	cout<<r<<endl;
}


#include <bits/stdc++.h>
using namespace std;
long long binomialCoeff(long long n, long long k)
{
	if(n<k)
	return 0;
    long long res = 1;

    // Since C(n, k) = C(n, n-k)
    if ( k > n - k )
        k = n - k;

    // Calculate value of [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]
    for (long long i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
int main()
{
	long long n;   cin>>n;
	long long a=0,b=0;
	for(long long i=0;i<n;++i)
	{
		long long x;  cin>>x;
		if(x==1||x%2==0)
		a++;
		else
		b++;
	}
//	cout<<a<<" "<<b<<endl;
	long long r = binomialCoeff(a,2) + binomialCoeff(b,2);
	cout<<r<<endl;
}


#include <bits/stdc++.h>
using namespace std;
long long binomialCoeff(long long n, long long k)
{
	if(n<k)
	return 0;
    long long res = 1;

    // Since C(n, k) = C(n, n-k)
    if ( k > n - k )
        k = n - k;

    // Calculate value of [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]
    for (long long i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
int main()
{
	map<long long,int> m;
	m[1] = 1;
	for(long long i=2;i<=100000;++i)
	{
		if(m[i]<1 && i%2==0 && m[i/2]>0)
		{
			m[i] = m[i/2];
			if(m[i+1]<1)
			m[i+1] = i+1;
			for(long long j=2*i;j<=10000;j=j*2)
			{
				m[j] = m[i];
				m[j+1] = m[i+1];
			}
		}
		else if(m[i]<1)
		{
		    m[i] = i;
			if(m[i+1]<1)
			m[i+1] = i+1;
			for(int j=2*i;j<=100000;j=j*2)
			{
				m[j] = m[i];
				m[j+1] = m[i+1];
			}
		}
	}
	long long n,r=0;   cin>>n;
	map<long long,int> p;
	for(long long i=1;i<=n;++i)
	{
		long long x;   cin>>x;
		p[m[x]]++;
	//	cout<<m[x]<<" ";
	}
//	cout<<endl;
	for(long long i=1;i<=100000;++i)
	{
		if(p[i]>1)
		r = r + binomialCoeff(p[i],2);
	}
	cout<<r<<endl;
}


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <bitset>
#include <string>
using namespace std;
#define ll long long

const int N = 100010;
int n, acc, ans, cnt[N];
ll ai;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for (int i=0; i < n; i++) {
        cin >> ai;
        cnt[__builtin_popcount(ai)]++;
    }

    for (int i=0; i <= 30; i++) {
        ans += cnt[i] * (cnt[i]-1) / 2;
    }
    cout << ans;

}


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <bitset>
#include <string>
using namespace std;
#define ll long long

const int N = 100010;
int n, acc, ans, cnt[N];
ll ai;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for (int i=0; i < n; i++) {
        cin >> ai;
        acc = 0;
        while (ai > 0) {
            if (ai&1)
                acc++;
            ai = ai >> 1;
        }
        cnt[acc]++;
    }

    for (int i=0; i < n; i++) {
        ans += cnt[i] * (cnt[i]-1) / 2;
    }
    cout << ans;

}


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <bitset>
#include <string>
using namespace std;
#define ll long long

const int N = 100010;
int n, acc, cnt[N];
ll ai, ans;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for (int i=0; i < n; i++) {
        cin >> ai;
        cnt[__builtin_popcount(ai)]++;
    }

    for (int i=0; i <= 30; i++) {
        ans += (ll) (cnt[i] * (cnt[i]-1) / 2);
    }
    cout << ans;

}


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <bitset>
#include <string>
using namespace std;
#define ll long long

const int N = 100010;
int n, acc, cnt[N];
ll ai, ans;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for (int i=0; i < n; i++) {
        cin >> ai;
        cnt[__builtin_popcount(ai)]++;
    }

    for (int i=0; i <= 30; i++) {
        ans += (ll) ((ll) (cnt[i] * (cnt[i]-1)) / 2);
    }
    cout << ans;

}


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <bitset>
#include <string>
using namespace std;
#define ll long long

const int N = 100010;
int n, acc, cnt[N];
ll ai, ans;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for (int i=0; i < n; i++) {
        cin >> ai;
        cnt[__builtin_popcount(ai)]++;
    }

    for (int i=0; i <= 30; i++) {
        ans += (cnt[i] * (cnt[i]-1)) / 2;
    }
    cout << ans;

}


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <bitset>
#include <string>
using namespace std;
#define ll long long

const int N = 100010;
ll n, acc, cnt[N];
ll ai, ans;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for (int i=0; i < n; i++) {
        cin >> ai;
        cnt[__builtin_popcount(ai)]++;
    }

    for (int i=0; i <= 30; i++) {
        ans += (cnt[i] * (cnt[i]-1)) / 2;
    }
    cout << ans;

}


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <bitset>
#include <string>
using namespace std;
#define ll long long

const int N = 100010;
int n, acc, cnt[N];
ll ai, ans;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for (int i=0; i < n; i++) {
        cin >> ai;
        cnt[__builtin_popcount(ai)]++;
    }

    for (int i=0; i <= 30; i++) {
        ans += cnt[i] * (cnt[i]-1) / 2;
    }
    cout << ans;

}


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <bitset>
#include <string>
using namespace std;
#define ll long long

const int N = 100010;
int n, acc, cnt[N];
ll ai, ans;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for (int i=0; i < n; i++) {
        cin >> ai;
        cnt[__builtin_popcount(ai)]++;
    }

    for (int i=0; i <= 30; i++) {
        ans += (ll) ((ll) (cnt[i] * (cnt[i]-1)) / (ll)2);
    }
    cout << ans;

}


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <bitset>
#include <string>
using namespace std;
#define ll long long

const int N = 100010;
int n, acc, cnt[N];
ll ai, ans;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for (int i=0; i < n; i++) {
        cin >> ai;
        cnt[__builtin_popcount(ai)]++;
    }

    for (int i=0; i <= 100; i++) {
        ans += cnt[i] * (cnt[i]-1) / 2;
    }
    cout << ans;

}


#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pii;
#define sf(x) scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define lli long long int
#define ll64 int64_t
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define frr(i,a) for(int i=0;i<a;i++)
#define frl(i,a) for(lli i=0;i<a;i++)

int main()
{
    lli n;
    cin>>n;
    lli a[n],e=0,o=0;
    frr(i,n)
    {
        cin>>a[i];
        if(a[i]==1 || a[i]%2==0)
        {
            e++;
        }
        else
        {
            o++;
        }
    }
    ll64 ans=((e*(e-1))+(o*(o-1)))/2;
    cout<<ans<<endl;
}