#include <bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define int long long
#define se second
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define op freopen
#define TXT "test"
#define freo if(fopen(TXT".inp","r")){op(TXT".inp","r",stdin);op(TXT".out","w",stdout);}
using namespace std;
int n,m,a[1000006*2],b[1000006*2];
int res=0;
main()
{
ios;
freo;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
for(int i=1;i<=m;i++)
{
cin>>b[i];
}
sort(a+1,a+1+n);
sort(b+1,b+1+m);
int c=1,i,res=0;
for(i=1;i<=m&&c<=n;i++)
{
while(c<=n&&a[c]<b[i])
{
c++;
}
if(a[c]>=b[i])
{
res+=a[c];
c++;
}
}
if(i>m)
{
cout<<res;
}
else
{
cout<<-1;
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgcGlpIHBhaXI8aW50LGludD4KI2RlZmluZSBmaSBmaXJzdAojZGVmaW5lIGludCBsb25nIGxvbmcKI2RlZmluZSBzZSBzZWNvbmQKI2RlZmluZSBpb3MgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7IGNpbi50aWUoTlVMTCk7IGNvdXQudGllKE5VTEwpOwojZGVmaW5lIG9wIGZyZW9wZW4KI2RlZmluZSBUWFQgInRlc3QiCiNkZWZpbmUgZnJlbyBpZihmb3BlbihUWFQiLmlucCIsInIiKSl7b3AoVFhUIi5pbnAiLCJyIixzdGRpbik7b3AoVFhUIi5vdXQiLCJ3IixzdGRvdXQpO30KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBuLG0sYVsxMDAwMDA2KjJdLGJbMTAwMDAwNioyXTsKaW50IHJlcz0wOwoKbWFpbigpCnsKICAgIGlvczsKICAgIGZyZW87CiAgICBjaW4+Pm4+Pm07CiAgICBmb3IoaW50IGk9MTtpPD1uO2krKykKICAgIHsKICAgICAgICBjaW4+PmFbaV07CiAgICB9CiAgICBmb3IoaW50IGk9MTtpPD1tO2krKykKICAgIHsKICAgICAgICBjaW4+PmJbaV07CiAgICB9CiAgICBzb3J0KGErMSxhKzErbik7CiAgICBzb3J0KGIrMSxiKzErbSk7CiAgICBpbnQgYz0xLGkscmVzPTA7CiAgICBmb3IoaT0xO2k8PW0mJmM8PW47aSsrKQogICAgewogICAgICAgIHdoaWxlKGM8PW4mJmFbY108YltpXSkKICAgICAgICB7CiAgICAgICAgICAgIGMrKzsKICAgICAgICB9CiAgICAgICAgaWYoYVtjXT49YltpXSkKICAgICAgICB7CiAgICAgICAgICAgIHJlcys9YVtjXTsKICAgICAgICAgICAgYysrOwogICAgICAgIH0KICAgIH0KICAgIGlmKGk+bSkKICAgIHsKICAgICAgICBjb3V0PDxyZXM7CiAgICB9CiAgICBlbHNlCiAgICB7CiAgICAgICAgY291dDw8LTE7CiAgICB9Cn0=