#include #include using namespace std; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; #define FAST_IO \ ios::sync_with_stdio(false); \ cin.tie(0); const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; int main() { FAST_IO auto ans = 0LL; int N,T; cin >> N >> T; vector t(N-1); for (auto& x : t) cin >> x; int K; cin >> K; vector x(K); for (auto& y : x) cin >> y; vector x2(N); for (int i = 0; i < K; i ++) { x2[x[i]-1] = true; } i64 tm = 0; for (int i = 0; i < N-1; i ++) { if (T + tm * 10 <= t[i]) { ans = -1; break; } T -= t[i]; if (T <= 0) { auto t = abs(T) / 10 + 1; T += t * 10; tm -= t; ans += t; } if (x2[i+1]) { tm ++; } } cout << ans << endl; }