#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;
}
unsigned long long readTimeStampCounter() {
  unsigned a = 123456789, b = 987654321;
  asm("rdtsc;\n\t" : "=d"(a), "=a"(b));
  return (unsigned long long)a << 32 | b;
}
unsigned xor128() {
  static unsigned x = 123456789, y = 362436069,
                  z = (unsigned)(readTimeStampCounter() >> 32),
                  w = (unsigned)readTimeStampCounter();
  unsigned t = x ^ (x << 11);
  x = y;
  y = z;
  z = w;
  return w = w ^ (w >> 19) ^ (t ^ (t >> 8));
}
struct PolynomialHash {
  static const int NumMods = 5;
  static const unsigned Mods[NumMods];
  struct Hash {
    unsigned hs[NumMods];
    Hash() {
      for (int k = 0; k < NumMods; ++k) hs[k] = 0;
    }
    bool operator==(const Hash &that) const {
      bool res = true;
      for (int k = 0; k < NumMods; ++k) res &= hs[k] == that.hs[k];
      return res;
    }
    bool operator<(const Hash &that) const {
      for (int k = 0; k < NumMods; ++k)
        if (hs[k] != that.hs[k]) return hs[k] < that.hs[k];
      return false;
    }
  };
  static unsigned seeds[NumMods];
  static std::vector<Hash> powh;
  static void initSeeds() {
    for (int k = 0; k < NumMods; ++k) {
      unsigned x;
      do x = xor128();
      while (x == 0 || x >= Mods[k]);
      seeds[k] = x;
    }
  }
  static void precomputePowerTable(int newSize) {
    if ((int)powh.size() >= newSize) return;
    if (seeds[0] == 0) initSeeds();
    int oldSize = powh.size();
    powh.resize(newSize);
    if (oldSize == 0)
      for (int k = 0; k < NumMods; ++k) powh[0].hs[k] = 1;
    for (int i = std::max(1, oldSize); i < newSize; i++)
      for (int k = 0; k < NumMods; ++k)
        powh[i].hs[k] =
            (unsigned long long)powh[i - 1].hs[k] * seeds[k] % Mods[k];
  }
};
const unsigned PolynomialHash::Mods[PolynomialHash::NumMods] = {
    2147483647U, 2147483629U, 2147483587U, 2147483579U, 2147483563U};
unsigned PolynomialHash::seeds[PolynomialHash::NumMods];
std::vector<PolynomialHash::Hash> PolynomialHash::powh;
struct SubstringHash : PolynomialHash {
  std::vector<Hash> preh;
  template <typename V>
  void init(const V &v, int n) {
    precomputePowerTable(n + 1);
    preh.resize(n + 1);
    preh[0] = Hash();
    for (int i = 0; i < n; i++)
      for (int k = 0; k < NumMods; ++k)
        preh[i + 1].hs[k] =
            ((unsigned long long)preh[i].hs[k] * seeds[k] % Mods[k] + v[i]) %
            Mods[k];
  }
  Hash hash(int j) const { return preh[j]; }
  Hash hash(int i, int j) const {
    if (i == 0) return hash(j);
    Hash res;
    for (int k = 0; k < NumMods; ++k) {
      unsigned x = preh[j].hs[k] + Mods[k] -
                   (unsigned)((unsigned long long)preh[i].hs[k] *
                              powh[j - i].hs[k] % Mods[k]);
      res.hs[k] = x >= Mods[k] ? x - Mods[k] : x;
    }
    return res;
  }
  Hash append(const Hash &h, const Hash &g, int glen) const {
    Hash res;
    for (int k = 0; k < NumMods; ++k) {
      unsigned x =
          (unsigned)((unsigned long long)h.hs[k] * powh[glen].hs[k] % Mods[k]) +
          g.hs[k];
      res.hs[k] = x >= Mods[k] ? x - Mods[k] : x;
    }
    return res;
  }
};
struct MultisetHash : PolynomialHash::Hash {
  static const int NumMods = PolynomialHash::NumMods;
  static void init(int n) { PolynomialHash::precomputePowerTable(n); }
  MultisetHash() : PolynomialHash::Hash() {}
  MultisetHash(int t) : PolynomialHash::Hash(PolynomialHash::powh[t]) {}
  MultisetHash &operator+=(const MultisetHash &that) {
    for (int k = 0; k < NumMods; ++k) {
      if ((hs[k] += that.hs[k]) >= PolynomialHash::Mods[k])
        hs[k] -= PolynomialHash::Mods[k];
    }
    return *this;
  }
  MultisetHash &operator-=(const MultisetHash &that) {
    for (int k = 0; k < NumMods; ++k) {
      if ((hs[k] += PolynomialHash::Mods[k] - that.hs[k]) >=
          PolynomialHash::Mods[k])
        hs[k] -= PolynomialHash::Mods[k];
    }
    return *this;
  }
  MultisetHash operator+(const MultisetHash &that) const {
    return MultisetHash(*this) += that;
  }
  MultisetHash operator-(const MultisetHash &that) const {
    return MultisetHash(*this) -= that;
  }
};
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);
  MultisetHash::init(n);
  MultisetHash qh;
  for (int(i) = 0; (i) < (int)(m); ++(i)) {
    int b;
    scanf("%d", &b), --b;
    qh += b;
  }
  MultisetHash 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;
}
