/*Grigory Shovkoplyas in the house*/
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<cstdlib>
#include<ctime>
using namespace std;

#define taskname "xpart"

int main()
{
  freopen(taskname".in", "r", stdin);
  freopen(taskname".out", "w", stdout);
  int n, x;
  long long suma = 0;long long sumb = 0;
  cin >> n >> x;
  vector<int> a(n), b(x);
  for (int i = 0; i < n; i++)
  {  cin >> a[i]; suma += a[i];}
  for (int i = 0; i < x; i++)
  {  cin >> b[i]; sumb += b[i];}
  long long cursum = 0;
  int k = 0;
  for (int i = 0; i < n && k < x; i++)
  {
    //cout << k << ' ' << cursum << endl;
    if(cursum >= b[k])
    {
      k++;
      cursum = 0;
    }  
    cursum += a[i];
  }
  //cerr << suma << ' ' << sumb << endl;
  //cout << cursum << ' ' << b[k] << endl;
  if(k < x - 1 || (k != x && cursum < b[k]))
    cout << -1 << endl;
  else
    cout << suma - sumb << endl;
  return 0;
}