#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int& x : a) scanf("%d", &x);
  int m;
  cin >> m;
  vector<int> b(m);
  for (int& x : b) scanf("%d", &x), x--;
  if (m == 1) return 0 * puts("0");
  vector<int> A;
  for (int i = 0; i < n; i++) A.push_back(i);
  for (int i = n - 2; i; i--) A.push_back(i);
  vector<int> B(A.size() + m + 1);
  for (int i = 0; i < B.size(); i++) B[i] = A[i % A.size()];
  long long Cost = 0;
  int Diff = 0;
  set<long long> All;
  vector<int> Cnt1(n);
  vector<int> Cnt2(n);
  for (int x : b) Cnt1[x]++;
  for (int i = 0; i < m; i++) Cnt2[B[i]]++;
  for (int i = 0; i < n; i++) Diff += (Cnt1[i] != Cnt2[i]);
  for (int i = 1; i < m; i++) Cost += abs(a[B[i]] - a[B[i - 1]]);
  for (int i = 0; i < A.size() && All.size() < 2; i++) {
    if (Diff == 0) All.insert(Cost);
    if (Cnt1[B[i]] == Cnt2[B[i]]) Diff++;
    Cnt2[B[i]]--;
    if (Cnt1[B[i]] == Cnt2[B[i]]) Diff--;
    if (Cnt1[B[i + m]] == Cnt2[B[i + m]]) Diff++;
    Cnt2[B[i + m]]++;
    if (Cnt1[B[i + m]] == Cnt2[B[i + m]]) Diff--;
    Cost -= abs(a[B[i + 1]] - a[B[i]]);
    Cost += abs(a[B[i + m]] - a[B[i + m - 1]]);
  }
  long long Ans = -1;
  if (All.size() == 1) Ans = *All.begin();
  cout << Ans << endl;
}
