#include //#include using namespace std; //using namespace atcoder; using ll = long long; //using mint = modint998244353; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); ll N, T, K, x, c=0, ans=0; cin >> N >> T; vector t(N); for (int i=1; i<=N-1; i++) cin >> t[i]; cin >> K; vector ok(N); for (int i=0; i> x; ok[x] = 1; } for (int i=1; i<=N-1; i++){ if (ok[i]) c++; T -= t[i]; if (T <= 0){ x = (-T+10-1)/10; if (x > c){ cout << -1 << endl; return 0; } T += 10 * x; c -= x; ans += x; if (T == 0){ if (c == 0){ cout << -1 << endl; return 0; } T += 10; c--; ans++; } } } cout << ans << endl; return 0; }