#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
inline istream& operator>>(istream& fin, pair<T1, T2>& pr) {
  fin >> pr.first >> pr.second;
  return fin;
}
template <class T0, class T1, class T2>
inline istream& operator>>(istream& fin, tuple<T0, T1, T2>& t) {
  fin >> get<0>(t) >> get<1>(t) >> get<2>(t);
  return fin;
}
template <class T>
inline istream& operator>>(istream& fin, vector<T>& a) {
  if (!a.size()) {
    size_t n;
    fin >> n;
    a.resize(n);
  }
  for (auto& u : a) fin >> u;
  return fin;
}
inline int64_t walk(int i, int di, vector<size_t> rep,
                    const vector<int64_t>& a) {
  int64_t val = 0;
  for (; rep[i]; i += di) {
    --rep[i];
    if (i + di < 0 || (int)a.size() == i + di) di = -di;
    if (rep[i + di]) val += abs(a[i] - a[i + di]);
  }
  return *max_element(begin(rep), end(rep)) ? -1 : val;
}
int64_t e534() {
  vector<int64_t> a;
  vector<size_t> b;
  cin >> a >> b;
  const auto n = a.size();
  vector<size_t> rep(n);
  for (const auto i : b) ++rep[i - 1];
  ;
  set<int64_t> val;
  val.insert(walk(0, 1, rep, a));
  val.insert(walk(n - 1, -1, rep, a));
  for (size_t i = 1; i + 1 < n && val.size() < 3; ++i) {
    if (rep[i - 1] < rep[i]) val.insert(walk(i, 1, rep, a));
    if (rep[i + 1] < rep[i]) val.insert(walk(i, -1, rep, a));
  }
  size_t i;
  for (i = 1; i + 1 < n; ++i)
    if (rep[i - 1] == rep[i + 1] && a[i] - a[i - 1] != a[i + 1] - a[i]) break;
  if (i + 1 < n) {
    val.insert(walk(i, 1, rep, a));
    val.insert(walk(i, -1, rep, a));
  }
  val.erase(-1);
  ;
  return val.size() == 1 ? *begin(val) : -1LL;
}
int main(const int argc, char* argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cout << e534();
  return EXIT_SUCCESS;
}
