#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void amax(T &x, U y) {
  if (x < y) x = y;
}
template <unsigned P>
struct UnorderedHash {
  unsigned long long x;
  static vector<unsigned long long> p;
  static void init(int n) {
    p.assign(n, 0);
    p[0] = 1;
    for (int(i) = (int)(1); (i) < (int)(n); ++(i)) p[i] = p[i - 1] * P;
  }
  UnorderedHash() : x(0) {}
  UnorderedHash(int t) : x(p[t]) {}
  UnorderedHash &operator+=(const UnorderedHash &that) {
    x += that.x;
    return *this;
  }
  UnorderedHash &operator-=(const UnorderedHash &that) {
    x -= that.x;
    return *this;
  }
  UnorderedHash operator+(const UnorderedHash &that) const {
    return UnorderedHash(*this) += that;
  }
  UnorderedHash operator-(const UnorderedHash &that) const {
    return UnorderedHash(*this) -= that;
  }
  bool operator==(const UnorderedHash<P> &that) const { return x == that.x; }
  bool operator<(const UnorderedHash<P> &that) const { return x < that.x; }
};
template <unsigned P>
vector<unsigned long long> UnorderedHash<P>::p;
struct UnorderedHashes {
  UnorderedHash<1000000007> h1;
  UnorderedHash<1000000009> h2;
  static void init(int n) {
    UnorderedHash<1000000007>::init(n);
    UnorderedHash<1000000009>::init(n);
  }
  UnorderedHashes() : h1(), h2() {}
  UnorderedHashes(int t) : h1(t), h2(t) {}
  UnorderedHashes &operator+=(const UnorderedHashes &that) {
    h1 += that.h1;
    h2 += that.h2;
    return *this;
  }
  UnorderedHashes &operator-=(const UnorderedHashes &that) {
    h1 -= that.h1;
    h2 -= that.h2;
    return *this;
  }
  UnorderedHashes operator+(const UnorderedHashes &that) const {
    return UnorderedHashes(*this) += that;
  }
  UnorderedHashes operator-(const UnorderedHashes &that) const {
    return UnorderedHashes(*this) -= that;
  }
  bool operator==(const UnorderedHashes &that) const {
    return h1 == that.h1 && h2 == that.h2;
  }
  bool operator<(const UnorderedHashes &that) const {
    return h1 < that.h1 || (h1 == that.h1 && h2 < that.h2);
  }
};
int geti(int i, int n) {
  i %= (n - 1) * 2;
  if (i <= n - 1)
    return i;
  else
    return (n - 1) * 2 - i;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int(i) = 0; (i) < (int)(n); ++(i)) scanf("%d", &a[i]);
  int m;
  scanf("%d", &m);
  UnorderedHashes::init(n);
  UnorderedHashes qh;
  for (int(i) = 0; (i) < (int)(m); ++(i)) {
    int b;
    scanf("%d", &b), --b;
    qh += b;
  }
  UnorderedHashes curh;
  long long curd = 0;
  for (int(i) = 0; (i) < (int)(m); ++(i)) {
    if (i != 0) curd += abs(a[geti(i - 1, n)] - a[geti(i, n)]);
    curh += geti(i, n);
  }
  vector<long long> v;
  for (int(i) = 0; (i) < (int)((n - 1) * 2); ++(i)) {
    if (curh == qh) v.push_back(curd);
    curd += abs(a[geti(i + m - 1, n)] - a[geti(i + m, n)]);
    curh += geti(i + m, n);
    curd -= abs(a[geti(i, n)] - a[geti(i + 1, n)]);
    curh -= geti(i, n);
  }
  if (v.empty()) {
    cerr << "err" << endl;
    abort();
  }
  if (count((v).begin(), (v).end(), v[0]) != v.size()) {
    puts("-1");
  } else {
    cout << v[0] << endl;
  }
  return 0;
}
