For this Question: You are given two sorted arrays A and B of size N and M respectively.

You have to find the value V, which is the summation of (A[j] - A[i]) for all pairs of i and j such that (j - i) is present in array B.The first line contains two space separated integers N and M – size of arrays A and B respectively.

The second line contains N integers A<sub>1</sub>, A<sub>2</sub>, ... A<sub>N</sub>.

The third line contains M integers B<sub>1</sub>, B<sub>2</sub>, ... B<sub>M</sub>.

<b> Constraints: </b>
1 ≤ N ≤ 2×10<sup>5</sup>
1 ≤ M < N
1 ≤ A<sub>1</sub> ≤ A<sub>2</sub> ≤ ... ≤ A<sub>N</sub> ≤ 10<sup>8</sup>.
1 ≤ B<sub>1</sub> < B<sub>2</sub> < ... < B<sub>M</sub> < N.Print a single integer, the value of V.Sample Input 1:
4 2
1 2 3 4
1 3

Sample Output 1:
6

Sample Explanation 1:
Valid pairs of (i, j) are (1, 2), (2, 3), (3, 4), (1, 4)., I have written this Solution Code: #include<bits/stdc++.h>
using namespace std;

#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define epsi (double)(0.00000000001)
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<pii>
#define vvi vector<vi>
//#define max(a,b) ((a>b)?a:b)
//#define min(a,b) ((a>b)?b:a)
#define min3(a,b,c) min(min(a,b),c)
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max3(a,b,c) max(max(a,b),c)
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define ff(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define REP(a,b,c) for(int a=b; a<c; a++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define ld long double
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define ub upper_bound
#define lb lower_bound
#define setbits(x) __builtin_popcountll(x)
#define trav(a,x) for(auto &a:x)
#define make_unique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rev(arr) reverse(all(arr))
#define gcd(a,b) __gcd(a,b);
#define ub  upper_bound // '>'
#define lb  lower_bound // '>='
#define qi queue<ll>
#define fsh cout.flush()
#define si stack<ll>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define fill(a,b) memset(a, b, sizeof(a))

template<typename T,typename E>bool chmin(T& s,const E& t){bool res=s>t;s=min<T>(s,t);return res;}

const ll INF=1LL<<60;

void solve(){
	ll n,m;
	cin >> n >> m;
	vi v1(n),v2(m);
	for(auto &i:v1){
		cin >> i;
	}
	for(auto &i:v2){
		cin >> i;
	}
	ll ans=0;
	for(int i=1 ; i<=n ; i++){
		auto it=lower_bound(all(v2),i);
		ll x=it-v2.begin();
		ans+=(x*v1[i-1]);
		it=lower_bound(all(v2),n-i+1);
		x=it-v2.begin();
		ans-=(x*v1[i-1]);
	}
	cout << ans << endl;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t=1;
	// cin >> t;
	while(t--){
		solve();
	}
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?