#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

int a[100001],b[100001],n,m;

int main()
{
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; ++i)
		scanf("%d",&a[i]);
	for (int i = 0; i < m; ++i)
		scanf("%d",&b[i]);
	sort(a,a+n);
	sort(b,b+m);
	long long s = 0;
	for (int i = 0; i < min(n,m); ++i)
		s += a[i]*b[i];
	cout << s << endl;
	return 0;
}
