#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int N, T, K; cin >> N >> T; vector t(N - 1); for (int i = 0; i < N - 1; i++) cin >> t[i]; cin >> K; unordered_set clockLocations; for (int i = 0; i < K; i++) { int x; cin >> x; clockLocations.insert(x - 1); // Store as 0-based index } deque dq; // Deque to store available clocks efficiently int timeLeft = T, clocksUsed = 0; for (int i = 0; i < N - 1; i++) { timeLeft -= t[i]; // Move to the next location if (timeLeft < 0) { // If time runs out before reaching cout << "-1\n"; return 0; } if (clockLocations.count(i)) dq.push_back(10); // Add +10 clock if available while (!dq.empty() && timeLeft < 0) { // Use clocks only when absolutely necessary timeLeft += dq.front(); dq.pop_front(); clocksUsed++; } if (timeLeft < 0) { // If we still can't proceed, fail cout << "-1\n"; return 0; } } cout << clocksUsed << "\n"; return 0; }