#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, m;     cin >> n >> m;     vector<int> a(n), b(m);     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < m; i++) cin >> b[i];     sort(a.begin(), a.end());     sort(b.begin(), b.end());     if (a[n - 1] > b[0]) {       cout << -1 << endl;       return 0;     }     long long sum = 0LL;     for (int i = 0; i < m; i++) sum = sum + 1LL * b[i];     for (int i = 0; i < n - 1; i++) sum = sum + 1LL * m * a[i];     if (n > 1 && b[0] > a[n - 1]) sum = sum + a[n - 1] - a[n - 2];     cout << sum << endl;   }   