#include #include using namespace std; using namespace atcoder; using ll = long long; using ld = long double; using ull = unsigned long long; using Graph = vector>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define NP next_permutation const int INF32 = 2e9; const ll INF64 = 2e18; const ll mod = 998244353; // const ll mod = 1e9 + 7; template bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;} template bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;} void cincout() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(15); } int main() { cincout(); int N, T; cin >> N >> T; vector t(N - 1); for (int i = 0; i < N - 1; i++) cin >> t[i]; int K; cin >> K; vector x(K); for (int i = 0; i < K; i++) cin >> x[i], x[i]--; int ans = 0, j = 0, watch = 0; for (int i = 0; i < N - 1; i++) { //i, i + 1 T -= t[i]; if (T <= 0) { int need = (10 - T) / 10; if (need <= watch) { T += need * 10; watch -= need; ans += need; } else { ans = -1; break; } } if (j < K && i + 1 == x[j]) { watch++; j++; } } cout << ans << endl; }