Example

Input

6 3
1 0 0 1 0 1
1 3 2


Output

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> b(n);
  vector<int> v;
  rep(i,n){
    cin >> b[i];
    if(b[i]){
      v.push_back(i);
    }
  }
  vector<int> p(m);
  rep(i,m) cin >> p[i];

  vector<int> a;
  int now=0;
  rep(i,m){
    rep(j,p[i]) a.push_back(now);
    now=1-now;
  }
  vector<int> va,vb;
  rep(i,n){
    if(a[i]){
      va.push_back(i);
    }else{
      vb.push_back(i);
    }
  }
  int ans=IINF,tmp;
  if(va.size()==v.size()){
    tmp=0;
    rep(i,v.size()) tmp+=abs(va[i]-v[i]);
    ans=min(ans,tmp);
  }
  if(vb.size()==v.size()){
    tmp=0;
    rep(i,v.size()) tmp+=abs(vb[i]-v[i]);
    ans=min(ans,tmp);
  }
  cout << ans << endl;
  return 0;
}

