#include #include #include using namespace std; using namespace __gnu_pbds; #define pb push_back #define int long long #define uint __int128 #define mp make_pair #define left left_compile #define right right_compile //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") const int INF = (int)1e18; const int md = (int)1e9 + 7; const int MAXN = (int)100; const int N = (int)4e6 + 111; //const int L = 20; const int debug = 0; const long double eps = 1e-7; //typedef tree< //int, //null_type, //less_equal, //rb_tree_tag, //tree_order_statistics_node_update> //ordered_set; int bpow(int a,int b){ if(b == 0) return 1ll; if(b % 2 == 0){ int t = bpow(a,b/2); return (t * t) % md; } return (a * bpow(a,b-1)) % md; } int inv(int a){ /// return 1/a by PRIME modulo md return bpow(a,md-2); } //void myerase(ordered_set& st, int t){ // int r = st.order_of_key(t); // ordered_set::iterator it = st.find_by_order(r); // st.erase(it); // return; //} mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); void init(){ return; } int n,m; void add(int& a,int b){ a += b; if(a >= m) a -= m; return; } void sub(int& a,int b){ a -= b; if(a < 0) a += m; return; } void solve_case(){ int n; cin >> n; int a[n+1]; a[0] = 0; int sum = 0; int cnt = 0; for(int i = 1; i <= n; i++){ cin >> a[i]; cnt += (a[i] == 1); sum += a[i]; } int number = n; while(number > 0){ int id; cin >> id; if(sum == a[id]){ cout << a[id] << "\n"; cout << "-1\n"; number--; sum -= a[id]; return; } if(a[id] == 1){ cout << "1\n"; number--; sum--; a[id] = 0; for(int i = 1; i <= n; i++){ if(a[i] == 1){ cout << i << "\n"; int x; cin >> x; a[i] -= x; number--; sum--; break; } } continue; } cout << a[id] - 1 << "\n"; cout << id << "\n"; sum -= a[id] - 1; a[id] -= a[id] - 1; int x; cin >> x; sum -= x; number--; } cout << "-1\n"; return; } signed main(){ // ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); // freopen("internship.in","r",stdin); // freopen("internship.out","w",stdout); // init(); int tests = 1; // cin >> tests; for(int _ = 1; _ <= tests; _++){ solve_case(); } return 0; } /* 4 <=> 100 7 <=> 111 3 <=> 011 0100 0111 0100 0101 */