#ifdef NACHIA #define _GLIBCXX_DEBUG #else #define NDEBUG #endif #include #include #include #include using i64 = long long; using u64 = unsigned long long; #define rep(i,n) for(i64 i=0; i void chmin(A& l, const A& r){ if(r < l) l = r; } template void chmax(A& l, const A& r){ if(l < r) l = r; } using namespace std; void testcase(){ i64 N, T; cin >> N >> T; vector A(N-1); rep(i,N-1) cin >> A[i]; i64 K; cin >> K; vector X(N); rep(i,K){ i64 x; cin >> x; X[x-1] += 1; } i64 cnt = 0, tim = T; i64 ans = 0; rep(i,N-1){ i64 w = 0; if(tim <= A[i]) w = (A[i] - tim) / 10 + 1; if(cnt < w){ cout << "-1\n"; return; } cnt -= w; ans += w; cnt += X[i+1]; tim += w * 10 - A[i]; } cout << ans << "\n"; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); rep(f,1) testcase(); return 0; }