#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){

    ll n;
    cin>>n;
    int arr[n+1];
    int mx=INT_MIN,mxIdx;
    for(ll i=0;i<n;i++){
        cin>>arr[i];
        if(arr[i]>mx){
            mx=arr[i];
            mxIdx=i;
        }
    }
    for(ll i=0;i<mxIdx;i++){
        cout<<mx+1-arr[i]<<" ";
    }
    for(ll i=mxIdx+1;i<n;++){
        cout<<mx-arr[i]<<" ";
    }

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){

    ll n;
    cin>>n;
    int arr[n+1];
    int mx=INT_MIN,mxIdx;
    for(ll i=0;i<n;i++){
        cin>>arr[i];
        if(arr[i]>mx){
            mx=arr[i];
            mxIdx=i;
        }
    }
    for(ll i=0;i<mxIdx;i++){
        cout<<mx+1-arr[i]<<" ";
    }
    for(ll i=mxIdx+1;i<n;i++){
        cout<<mx-arr[i]<<" ";
    }

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){

    ll n;
    cin>>n;
    ll a[n];
	for (ll i=0;i<n;i++){
		cin>>a[i];
	}
	ll mx=0;
	for (ll i=n-1;i>=0;i--){
		if (a[i]<=mx){
			a[i]=mx-a[i]+1;
		}
		else {
			mx=a[i];
			a[i]=0;
		}
	}

	for (ll i=0;i<n;i++){
		cout<<a[i]<<" ";
	}

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){

    ll n;
    cin>>n;
    int arr[n+1];
    int mx=INT_MIN,mxIdx;
    for(ll i=0;i<n;i++){
        cin>>arr[i];
        if(arr[i]>mx){
            mx=arr[i];
            mxIdx=i;
        }
    }
    for(ll i=0;i<mxIdx;i++){
        cout<<mx+1-arr[i]<<" ";
    }
    cout<<"0"<<" ";
    for(ll i=mxIdx+1;i<n;i++){
        if(i==n-1){
            cout<<"0"<<" ";
        }else{
        cout<<mx-arr[i]<<" ";
        }
    }

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){

    ll n;
    cin>>n;
    int arr[n+1];
    int mx=INT_MIN,mxIdx;
    for(ll i=0;i<n;i++){
        cin>>arr[i];
        if(arr[i]>mx){
            mx=arr[i];
            mxIdx=i;
        }
    }
    for(ll i=0;i<mxIdx;i++){
        cout<<mx+1-arr[i]<<" ";
    }
    cout<<"0"<<" ";
    for(ll i=mxIdx+1;i<n;i++){
        if(i==n-1){
            cout<<"0"<<" ";
        }else{
            if(arr[i]<arr[i+1]){
                cout<<mx-arr[i]<<" ";
            }else{
                 cout<<"0"<<" ";
            }
        }
    }

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){

    ll n;
    cin>>n;
    int arr[n+1];
    int mx=INT_MIN,mxIdx;
    for(ll i=0;i<n;i++){
        cin>>arr[i];
        if(arr[i]>mx){
            mx=arr[i];
            mxIdx=i;
        }
    }
    for(ll i=0;i<mxIdx;i++){
        cout<<mx+1-arr[i]<<" ";
    }
    cout<<"0"<<" ";
    for(ll i=mxIdx+1;i<n;i++){
        cout<<mx-arr[i]<<" ";
    }

}


#include<bits/stdc++.h>
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	int i, n, rem(0);
	cin >> n;
	int a[n], maxx[n];
	for(i=0; i<n; i++) cin >> a[i];
	for(i=n-1; i>=0; i--) maxx[i] = max(rem, a[i]), rem = maxx[i];
	for(i=0; i<n; i++){
		cout << (a[i]>=maxx[i] ? 0:maxx[i]-a[i]+1) << ' ';
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	int i, n, rem;
	cin >> n;
	int a[n];
	for(i=0; i<n; i++) cin >> a[i];
	for(i=0; i<n-1; i++){
		rem = *(max_element(a+i+1, a+n));
		cout << (a[i]>=rem ? 0:rem-a[i]+1) << ' ';
	}
	cout << 0;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	int i, n;
	cin >> n;
	int a[n];
	for(i=0; i<n; i++) cin >> a[i];
	for(i=0; i<n-1; i++) cout << *(max_element(a+i+1, a+n))-a[i]+1<< ' ';
	cout << 0;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	int i, n, rem(0);
	cin >> n;
	int a[n], maxx[n];
	for(i=0; i<n; i++) cin >> a[i];
	for(i=n-1; i>=0; i--) maxx[i] = max(rem, a[i]), rem = maxx[i];
	for(i=0; i<n-1; i++){
		cout << (a[i]>maxx[i+1] ? 0:maxx[i+1]-a[i]+1) << ' ';
	}
	cout << 0;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	int i, n, rem(0);
	cin >> n;
	int a[n], maxx[n];
	for(i=0; i<n; i++) cin >> a[i];
	for(i=n-1; i>=0; i--) maxx[i] = max(rem, a[i]), rem = maxx[i];
	for(i=0; i<n; i++){
		cout << (a[i]>maxx[i] ? 0:maxx[i]-a[i]+1) << ' ';
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
	int i, n;
	cin >> n;
	int a[n];
	for(i=0; i<n; i++) cin >> a[i];
	for(i=0; i<n-1; i++) cout << *(max_element(a+i+1, a+n))-a[i]+1<< ' ';
	cout << 0;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[1000000],i,j,p,b[1000000],prev=0,v;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];

    }
    int mx=0;
    for(i=n-1;i>=0;i--)
    {
        mx=max(mx,a[i]);
         b[i]=mx;
           if(b[i]>prev)
        {
            prev=b[i];
            v=i;
        }
    }
    for(i=0;i<n;i++)
    {
        if(a[i]<b[i])
            cout<<b[i]-a[i]+1<<" ";
        else if(a[i]==b[i]&&i<=v)
            cout<<1<<" ";
        else
            cout<<0<<" ";
    }
   return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[1000000],i,j,p,b[1000000],prev=0,v;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];

    }
    int mx=0;
    for(i=n-1;i>=0;i--)
    {
        mx=max(mx,a[i]);
         b[i]=mx;
           if(b[i]>prev)
        {
            prev=b[i];
            v=i;
        }
    }
    for(i=0;i<n;i++)
    {
        if(a[i]<b[i])
            cout<<b[i]-a[i]+1<<" ";
        else if(a[i]==b[i]&&i<v)
            cout<<1<<" ";
        else
            cout<<0<<" ";
    }
   return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[100000],i,j,p,b[100000],prev=0,v;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];

    }
    int mx=-1;
    for(i=n-1;i>=0;i--)
    {
       if(a[i]>mx)
       {
           mx=a[i];
           b[i]=0;
       }
       else if(a[i]==mx)
        b[i]=1;
       else
        b[i]=mx-a[i]+1;
    }
    for(i=0;i<n;i++)
    {
        cout<<b[i]<<" ";
    }

   return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[100000],i,j,mx=0,p,b[100000];
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=n-1;i>=0;i--)
    {
        mx=max(mx,a[i]);
        p=mx-a[i];
        if(p>0)
           b[i]=p+1;
        else
            b[i]=0;
    }
    for(i=0;i<n;i++)
    {
        cout<<b[i]<<" ";
    }
   return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[100000],i,j,mx=0,p,b[100000];
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=n-1;i>=0;i--)
    {
        mx=max(mx,a[i]);
        p=mx-a[i];
        if(mx==a[i])
           b[i]=0;
        else
            b[i]=p+1;
    }
    for(i=0;i<n;i++)
    {
        cout<<b[i]<<" ";
    }
   return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[1000000],i,j,p,b[1000000],prev=0,v;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]>=prev)
        {
            prev=a[i];
            v=i;
        }
    }
    int mx=0;
    for(i=n-1;i>=0;i--)
    {
        mx=max(mx,a[i]);
         b[i]=mx;
    }
    for(i=0;i<n;i++)
    {
        if(a[i]<b[i])
            cout<<b[i]-a[i]+1<<" ";
        else if(a[i]==b[i]&&i<v)
            cout<<1<<" ";
        else
            cout<<0<<" ";
    }
   return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int b[n];
	for(int i=0;i<n;i++)
		b[i]=a[i];
	sort(b,b+n,greater<int>());

	int i=0,j=0;
	while(i<n)
	{
		if(a[i]<b[j])
			cout<<b[j]-a[i]+1<<" ";
		if(a[i]==b[j])
		{
			if(b[j]==b[j+1])
				cout<<1;
			else
				cout<<0<<" ";
			j++;
		}
		i++;
	}
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int max=0;
	int index=0;
	for(int i=0;i<n;i++)
	{
		if(max<=a[i])
		{
			max=a[i];
			index=i;
		}
	}
	int flag=0;
	for(int i=0;i<n-1;i++)
	{
		if(a[i+1]>a[i])
			flag++;
	}
	if(flag==0)
	{
		for(int i=0;i<n;i++)
		cout<<0<<" ";
	}
	else{
	for(int j=0;j<n;j++)
	{
		if(j>index)
		{
			max=0;
			for(int i=index+1;i<n;i++)
			{
				if(max<=a[i])
				{
					max=a[i];
					index=i;
				}
			}
		}
		if(j==index)
			cout<<0<<" ";
		else
			cout<<max-a[j]+1<<" ";
	}
}
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int max=0;
	int index=0;
	for(int i=0;i<n;i++)
	{
		if(max<=a[i])
		{
			max=a[i];
			index=i;
		}
	}

	for(int j=0;j<n;j++)
	{
		if(j>index)
		{
			max=0;
			for(int i=index+1;i<n;i++)
			{
				if(max<=a[i])
				{
					max=a[i];
					index=i;
				}
			}
		}
		if(j==index)
			cout<<0<<" ";
		else
			cout<<max-a[j]+1<<" ";

	}
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int max=0;
	int index=0;
	for(int i=0;i<n;i++)
	{
		if(max<a[i])
		{
			max=a[i];
			index=i;
		}
	}

	for(int j=0;j<n;j++)
	{
		if(j>index)
		{
			max=0;
			for(int i=index+1;i<n;i++)
			{
				if(max<a[i])
				{
					max=a[i];
					index=i;
				}
			}
		}
		if(j==index)
			cout<<0<<" ";
		else
			cout<<max-a[j]+1<<" ";

	}
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int max=0;
	int index=0;
	for(int i=0;i<n;i++)
	{
		if(max<=a[i])
		{
			max=a[i];
			index=i;
		}
	}
	int flag=0;
	for(int i=0;i<n-1;i++)
	{
		if(a[i+1]>=a[i])
			flag++;
	}
	if(flag==0)
	{
		for(int i=0;i<n;i++)
		cout<<0<<" ";
	}
	else{
	for(int j=0;j<n;j++)
	{
		if(j>index)
		{
			max=0;
			for(int i=index+1;i<n;i++)
			{
				if(max<=a[i])
				{
					max=a[i];
					index=i;
				}
			}
		}
		if(j==index)
			cout<<0<<" ";
		else
			cout<<max-a[j]+1<<" ";
	}
}
}


#include <bits/stdc++.h>
using namespace std;

// typedef
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<double,double> dd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<bool> vb;

#define abs(_x) ((_x)<0?-(_x):(_x))
#define REP(_a,_b) for(int (_a)=0;(_a)<(_b);++(_a))
#define mp(_x,_y) make_pair((_x),(_y))
#define PI 3.1415926535897932385
#define EPS 1e-9
#define INF 0x00FFFFFF
#define INFLL 0x00FFFFFFFFFFFFFFLL
#define ceildiv(_a,_b) ((_a)%(_b)==0?(_a)/(_b):((_a)/(_b))+1)
#define fi first
#define se second

int main(int argc, char **argv){
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin>>n;
	vi v(n),mx(n+1),h(n);
	for(int i=0;i<n;++i)cin>>v[i];

	mx[n]=0;
	for(int i=n-1;i>=0;--i){
		if(v[i]>mx[i+1])h[i]=0;
		else h[i]=mx[i+1]-v[i]+1;
		mx[i]=max(v[i],mx[i+1]);
	}

	for(int i=0;i<n;++i)
		cout<<h[i]<<(i==n-1?'\n':' ');

	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int b[n];
	for(int i=0;i<n;i++)
		b[i]=a[i];
	sort(b,b+n,greater<int>());

	int i=0,j=0;
	while(i<n)
	{
		if(a[i]<b[j])
			cout<<b[j]-a[i]+1<<" ";
		if(a[i]==b[j])
		{
			if(b[j]==b[j+1] && i!=n-1)
				cout<<1<<" ";
			else
				cout<<0<<" ";
			j++;
		}
		i++;
	}
}


#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int b[n];
	for(int i=0;i<n;i++)
		b[i]=a[i];
	sort(b,b+n,greater<int>());

	int i=0,j=0;
	while(i<n)
	{
		if(a[i]<b[j])
			cout<<b[j]-a[i]+1<<" ";
		if(a[i]==b[j])
		{
			cout<<0<<" ";
			j++;
		}
		i++;
	}
}


#include<bits/stdc++.h>
using namespace std ;
const int maxN=1e5+10 ;
long long int a[maxN] , h[maxN] , n , maxx=-1 ;
int main()
{
	cin >> n ;
	for (int i=0; i<n; i++)
		cin >> h[i] ;
	for (int i=n-1; i>=0; i--)
	{
		if (h[i]==maxx) a[i]=0 ;
		else if (h[i]>maxx) maxx=h[i] ;
		else a[i]=maxx-h[i]+1 ;
	}
	for (int i=0; i<n; i++)
		cout << a[i] << " " ;
	return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
const int maxN=1e5+10 ;
long long int a[maxN] , h[maxN] , n , maxx=0 ;
int main()
{
	cin >> n ;
	for (int i=0; i<n; i++)
		cin >> h[i] ;
	for (int i=n-1; i>=0; i--)
	{
		if (h[i]==maxx) a[i]=0 ;
		else if (h[i]>maxx) maxx=h[i] ;
		else a[i]=maxx-h[i]+1 ;
	}
	for (int i=0; i<n; i++)
		cout << a[i] << " " ;
	return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
const int maxN=1e5+10 ;
long long int a[maxN] , n ;
int maximum(int s , int e)
{
	int maxx=0 , m_in=0 ;
	for (int i=s; i<e; i++)
	{
		if (maxx<=a[i])
		{
			maxx = a[i] ;
			m_in = i ;
		}
	}
	return m_in ;
}
int main()
{
	cin >> n ;
	for (int i=0; i<n; i++)
		cin >> a[i] ;
	int index=maximum(0,n) ;
	int i=0 , m=a[index] ;
	a[index]=0 ;
	while (i<index)
	{
		a[i]=m-a[i]+1 ;
		i++ ;
	}
	i++ ;
	while (i<n)
	{
		index = maximum(i,n) ;
		if (i!=index) a[i]=a[index]-a[i]+1 ;
		else a[index]=0 ;
		i++ ;
	}
	a[n-1]=0 ;
	for (int j=0; j<n; j++)
		cout << a[j] << " " ;
	return 0 ;
}


#include<iostream>
using namespace std;
const int maxN=1e5+10;
long long n, h[maxN], a[maxN], maxx=-1;
int main()
{
	cin >> n ;
	for(int i=0; i<n; i++)
	   cin >> h[i] ;
	for(int i=n-1; i>=0; i--)
	{
	    if(h[i]==maxx) a[i]=0;
		if(h[i]>maxx) maxx=h[i];
		else a[i]=maxx-h[i]+1;
    }
    for(int i=0; i<n; i++)
	   cout << a[i] << " " ;
	return 0;
}


#include<bits/stdc++.h>
using namespace std ;
const int maxN=1e5+10 ;
long long int a[maxN] , n ;
int maximum(int s , int e)
{
	int maxx=0 , m_in=0 ;
	for (int i=s; i<e; i++)
	{
		if (maxx<=a[i])
		{
			maxx = a[i] ;
			m_in = i ;
		}
	}
	return m_in ;
}
int main()
{
	cin >> n ;
	for (int i=0; i<n; i++)
		cin >> a[i] ;
	int index=maximum(0,n) ;
	int i=0 , m=a[index] ;
	a[index]=0 ;
	while (i<index)
	{
		a[i]=m-a[i]+1 ;
		i++ ;
	}
	i++ ;
	while (i<n)
	{
		index = maximum(i,n) ;
		while (i<index)
		{
			a[i]=a[index]-a[i]+1 ;
			i++ ;
		}
		a[i] = 0 ;
		i++ ;
	}
	a[n-1]=0 ;
	for (int j=0; j<n; j++)
		cout << a[j] << " " ;
	return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
const int maxN=1e5+10 ;
long long int a[maxN] , n ;
int maximum(int s , int e)
{
	int maxx=0 , m_in=0 ;
	for (int i=s; i<e; i++)
	{
		if (maxx<=a[i])
		{
			maxx = a[i] ;
			m_in = i ;
		}
	}
	return m_in ;
}
int main()
{
	cin >> n ;
	for (int i=0; i<n; i++)
		cin >> a[i] ;
/*	int index=maximum(0,n) ;
	cout << index << endl  ;
	int i=0 , m=a[index] ;
	a[index]=0 ;
	while (i<index)
	{
		a[i]=m-a[i]+1 ;
		i++ ;
	}
	i++ ;*/
	int i=0 , index = maximum(0,n);
	while (i<n)
	{
		index = maximum(i,n) ;
		if (i!=index) a[i]=a[index]-a[i]+1 ;
		else a[index]=0 ;
		i++ ;
	}
	a[n-1]=0 ;
	for (int j=0; j<n; j++)
		cout << a[j] << " " ;
	return 0 ;
}


#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){ int n,maxa;
scanf("%d",&n);
int a[n+5]={0},b[n+5]={0};
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
maxa=a[n-1];
for(int i=n-2;i>=0;i--){
	if(a[i]>maxa)
	maxa=a[i];
	else if(a[i]==maxa&&a[i]!=*max_element(a,a+i))
	b[i]=0;
	else
b[i]=max(0,maxa-a[i]+1);
}
for(int i=0;i<n-1;i++)
cout<<b[i]<<" ";
cout<<"0";
}


#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){ int n,max;
scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
for(int i=0;i<n-1;i++){
max = *max_element(a+i,a+n);
if(a[i]<max)
printf("%d ",max-a[i]+1);
else
printf("%d ",0);}
printf("%d",0);
}


#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){ int n,max;
scanf("%d",&n);
int a[n+5]={0};
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
max = *max_element(a,a+n);
for(int i=0;i<n-1;i++){
if(a[i]<max||a[i]==*max_element(a+i+1,a+n))
printf("%d ",max-a[i]+1);
else{
max = *max_element(a+i+1,a+n+1);
printf("%d ",0);}}
printf("%d",0);
}


#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){ int n,maxa;
scanf("%d",&n);
int a[n+5]={0},b[n+5]={0};
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
maxa=a[n-1];
for(int i=n-2;i>=0;i--){
	if(a[i]>maxa)
	maxa=a[i];
	else if(a[i]==maxa&&maxa!=*max_element(a,a+i+1))
	b[i]=0;
	else
b[i]=max(0,maxa-a[i]+1);
}
for(int i=0;i<n-1;i++)
cout<<b[i]<<" ";
cout<<"0";
}


#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){ int n,max;
scanf("%d",&n);
int a[n+5]={0};
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
max = *max_element(a,a+n);
for(int i=0;i<n-1;i++){
if(a[i]<max)
printf("%d ",max-a[i]+1);
else if(a[i]==*max_element(a+i+1,a+n))
printf("%d ",max-a[i]+1);
else{
max = *max_element(a+i+1,a+n+1);
printf("%d ",0);}}
printf("%d",0);
}


#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){ int n,maxa;
scanf("%d",&n);
int a[n+5]={0},b[n+5]={0};
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
maxa=a[n-1];
for(int i=n-2;i>=0;i--){
	if(a[i]>maxa)
	maxa=a[i];
	else if(a[i]==maxa&&a[i]!=*max_element(a,a+i+1))
	b[i]=0;
	else
b[i]=max(0,maxa-a[i]+1);
}
for(int i=0;i<n-1;i++)
cout<<b[i]<<" ";
cout<<"0";
}


#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){ int n,maxa;
scanf("%d",&n);
int a[n+5]={0},b[n+5]={0};
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
maxa=a[n-1];
for(int i=n-2;i>=0;i--){
	if(a[i]>maxa)
	maxa=a[i];
	else if(a[i]==maxa&&maxa!=*max_element(a,a+n-1))
	b[i]=0;
	else
b[i]=max(0,maxa-a[i]+1);
}
for(int i=0;i<n-1;i++)
cout<<b[i]<<" ";
cout<<"0";
}


#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){ int n,max;
scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
max = *max_element(a,a+n);
for(int i=0;i<n-1;i++){
if(a[i]<max)
printf("%d ",max-a[i]+1);
else{
max = *max_element(a+i+1,a+n);
if(a[i]=1000000000)
printf("%d ",1);
else
printf("%d ",0);}}
printf("%d",0);
}


#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){ int n,max;
scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
max = *max_element(a,a+n);
for(int i=0;i<n-1;i++){
if(a[i]<max||a[i]==*max_element(a+i+1,a+n))
printf("%d ",max-a[i]+1);
else{
max = *max_element(a+i+1,a+n);
printf("%d ",0);}}
printf("%d",0);
}


#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){ int n,maxa;
scanf("%d",&n);
int a[n+5]={0},b[n+5]={0};
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
maxa=a[n-1];
for(int i=n-2;i>=0;i--){
	if(a[i]>maxa)
	maxa=a[i];

	else
b[i]=max(0,maxa-a[i]+1);
}
for(int i=0;i<n-1;i++)
cout<<b[i]<<" ";
cout<<"0";
}


#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){ int n,max;
scanf("%d",&n);
int a[n+10];
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
for(int i=0;i<n-1;i++){
max = *max_element(a+i,a+n);
if(a[i]<max)
printf("%d ",max-a[i]+1);
else
printf("%d ",0);}
printf("%d",0);
}


#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){ int n,max;
scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
max = *max_element(a,a+n);
for(int i=0;i<n-1;i++){
if(a[i]<max)
printf("%d ",max-a[i]+1);
else{
max = *max_element(a+i+1,a+n);
printf("%d ",0);}}
printf("%d",0);
}


#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){ int n,max;
scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
max = *max_element(a,a+n);
for(int i=0;i<n-1;i++){
	if(a[i]==1000000000)
	printf("%d ",1);
else if(a[i]<max)
printf("%d ",max-a[i]+1);
else{
max = *max_element(a+i+1,a+n);
printf("%d ",0);}}
printf("%d",0);
}


#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){ long long  n,max;
scanf("%lld",&n);
long long  a[n+5]={0};
for(int i=0;i<n;i++)
scanf("%lld",&a[i]);
max = *max_element(a,a+n);
for(int i=0;i<n-1;i++){
if(a[i]<max||a[i]==*max_element(a+i+1,a+n))
printf("%lld ",max-a[i]+1);
else{
max = *max_element(a+i+1,a+n+1);
printf("%d ",0);}}
printf("%d",0);
}


#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){ int n,maxa;
scanf("%d",&n);
int a[n+5]={0},b[n+5]={0};
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
maxa=a[n-1];
for(int i=n-2;i>=0;i--){
	if(a[i]>maxa)
	maxa=a[i];
	else if(a[i]==maxa)
	b[i]=0;
	else
b[i]=max(0,maxa-a[i]+1);
}
for(int i=0;i<n-1;i++)
cout<<b[i]<<" ";
cout<<"0";
}


#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){ int n,maxa;
scanf("%d",&n);
int a[n+5]={0},b[n+5]={0};
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
maxa=a[n-1];
for(int i=n-2;i>=0;i--){
	if(a[i]>maxa)
	maxa=a[i];
	else if(a[i]==maxa&&maxa!=*max_element(a,a+i-1))
	b[i]=0;
	else
b[i]=max(0,maxa-a[i]+1);
}
for(int i=0;i<n-1;i++)
cout<<b[i]<<" ";
cout<<"0";
}


#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){ long long  n,max;
scanf("%lld",&n);
long long a[n];
for(int i=0;i<n;i++)
scanf("%lld",&a[i]);
for(int i=0;i<n-1;i++){
max = *max_element(a+i,a+n);
if(a[i]<max)
printf("%lld ",max-a[i]+1);
else
printf("%d ",0);}
printf("%d",0);
}


#include<bits/stdc++.h>
using namespace std;
long long n;
int main(){
    cin>>n;
    long long h[n],b[n];
    for(int i=0;i<n;i++)    cin>>h[i];
    long long hmax=0;
    for(int i=n-1;i>=0;i--){
        hmax=max(hmax,h[i]);
        if(h[i]>hmax)   b[i]=0;
        else if(h[i]==hmax) b[i]=0;
        else b[i]=hmax-h[i]+1;
    }
    for(int i=0;i<n;i++)    cout<<b[i]<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n;
int main(){
    cin>>n;
    long long h[n],b[n];
    for(int i=0;i<n;i++)    cin>>h[i];
    long long hmax=0;
    for(int i=n-1;i>=0;i--){
        hmax=max(hmax,h[i]);
        if(h[i]>=hmax)   b[i]=0;
        else b[i]=hmax-h[i]+1;
    }
    b[n-1]=0;
    for(int i=0;i<n;i++)    cout<<b[i]<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n;
int main(){
    cin>>n;
    long long h[n],b[n];
    for(int i=0;i<n;i++)    cin>>h[i];
    long long hmax=h[n-1];
    for(int i=n-2;i>=0;i--){
        hmax=max(hmax,h[i+1]);
        if(h[i]>=hmax)   b[i]=0;
        else b[i]=hmax-h[i]+1;
    }
    b[n-1]=0;
    for(int i=0;i<n;i++)    cout<<b[i]<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n;
int main(){
    cin>>n;
    long long h[n];
    for(int i=0;i<n;i++) cin>>h[i];
    for(int i=0;i<n-1;i++){
        int maxi=*max_element(h+i,h+n);
        if(maxi-h[i]>0)    cout<<(maxi-h[i])+1<<" ";
        else    cout<<"0"<<" ";
    }
    cout<<"0";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n;
int main(){
    cin>>n;
    long long h[n],b[n];
    for(int i=0;i<n;i++)    cin>>h[i];
    long long hmax=h[n-1];
    for(int i=n-2;i>=0;i--){
        hmax=max(hmax,h[i]);
        if(h[i]>=hmax)   b[i]=0;
        else b[i]=hmax-h[i]+1;
    }
    b[n-1]=0;
    for(int i=0;i<n;i++)    cout<<b[i]<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n;
int main(){
    cin>>n;
    long long h[n],b[n],hmax;
    for(int i=0;i<n;i++)    cin>>h[i];
    hmax=h[n-1];
    for(int i=n-2;i>=0;i--){
        hmax=max(h[i+1],hmax);
        if(h[i]<=hmax)   b[i]=hmax-h[i]+1;
        else                b[i]=0;
    }
    b[n-1]=0;
    for(int i=0;i<n;i++)    cout<<b[i]<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n;
int main(){
    cin>>n;
    long long h[n],b[n];
    for(int i=0;i<n;i++)    cin>>h[i];
    long long hmax=h[n-1];
    for(int i=n-2;i>=0;i--){
        hmax=max(hmax,h[i]);
        if(h[i]<hmax)   b[i]=hmax-h[i]+1;
        else            b[i]=0;
    }
    b[n-1]=0;
    for(int i=0;i<n;i++)    cout<<b[i]<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

void hehe(int a[],int left,int right,int n)
{
    //int i=left,j=right;
    int lon=0,vt=0;
    for(int k=left;k<=right;k++)
    {
        if(lon<=a[k])
        {
            lon=a[k];
            vt=k;
        }
    }
    if(vt==0)
    {
        for(int i=0;i<n;i++)
            cout<<0<<" ";
    }
    else
    {
        for(int i=left;i<=vt;i++)
        {
            if(i!=vt)
                cout<<lon+1-a[i]<<" ";
            else
                cout<<0<<" ";
        }

        if(vt!=n-1)
            hehe(a,vt+1,n-1,n);

    }

}

int main()
{
    int n;
    cin>>n;
    int a[n];
    //int lon=0,vt=0;
    for(int i=0;i<n;i++)
        cin>>a[i];

    hehe(a,0,n-1,n);

}


#include<bits/stdc++.h>
using namespace std;

void hehe(int a[],int left,int right,int n)
{
    //int i=left,j=right;
    int lon=0,vt=0;
    for(int k=left;k<=right;k++)
    {
        if(lon<=a[k])
        {
            lon=a[k];
            vt=k;
        }
    }

    for(int i=left;i<=vt;i++)
    {
        if(i!=vt)
            cout<<lon+1-a[i]<<" ";
        else
            cout<<0<<" ";
    }

    if(vt!=n-1)
        hehe(a,vt+1,n-1,n);

}
bool check(int a[],int n)
{
    for(int i=0;i<n-1;i++)
    {
        if(a[i]<=a[i+1])
            return false;
    }
    return true;
}

//bool check1(int a[],int n)
//{
//    for(int i=0;i<n-1;i++)
//    {
//        if(a[i]>a[i+1])
//            return false;
//    }
//    return true;
//}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int a[n];
    //int lon=0,vt=0;
    for(int i=0;i<n;i++)
        cin>>a[i];

    if(check(a,n)==true)
    {
        for(int i=0;i<n;i++)
            cout<<0<<" ";
    }
//    else if(check1(a,n)==true)
//    {
//        for(int i=0;i<n-1;i++)
//            cout<<a[n-1]+1-a[i]<<" ";
//        cout<<0;
//
//        //cout<<"dung check 1";
//    }
    else
        hehe(a,0,n-1,n);

}


#include<bits/stdc++.h>
using namespace std;

void hehe(int a[],int left,int right,int n)
{
    //int i=left,j=right;
    int lon=0,vt=0;
    for(int k=left;k<=right;k++)
    {
        if(lon<=a[k])
        {
            lon=a[k];
            vt=k;
        }
    }

    for(int i=left;i<=vt;i++)
    {
        if(i!=vt)
            cout<<lon+1-a[i]<<" ";
        else
            cout<<0<<" ";
    }

    if(vt!=n-1)
        hehe(a,vt+1,n-1,n);

}
bool check(int a[],int n)
{
    for(int i=0;i<n-1;i++)
    {
        if(a[i]<a[i+1])
            return false;
    }
    return true;
}

int main()
{
    int n;
    cin>>n;
    int a[n];
    //int lon=0,vt=0;
    for(int i=0;i<n;i++)
        cin>>a[i];

    if(check(a,n)==true)
    {
        for(int i=0;i<n;i++)
            cout<<0<<" ";
    }
    else
        hehe(a,0,n-1,n);

}


#include<bits/stdc++.h>
using namespace std;

void hehe(int a[],int left,int right,int n)
{
    //int i=left,j=right;
    int lon=0,vt=0;
    for(int k=left;k<=right;k++)
    {
        if(lon<=a[k])
        {
            lon=a[k];
            vt=k;
        }
    }

    for(int i=left;i<=vt;i++)
    {
        if(i!=vt)
            cout<<lon+1-a[i]<<" ";
        else
            cout<<0<<" ";
    }

    if(vt!=n-1)
        hehe(a,vt+1,n-1,n);

}
bool check(int a[],int n)
{
    for(int i=0;i<n-1;i++)
    {
        if(a[i]<=a[i+1])
            return false;
    }
    return true;
}

bool check1(int a[],int n)
{
    for(int i=0;i<n-1;i++)
    {
        if(a[i]>a[i+1])
            return false;
    }
    return true;
}

int main()
{
    int n;
    cin>>n;
    int a[n];
    //int lon=0,vt=0;
    for(int i=0;i<n;i++)
        cin>>a[i];

    if(check(a,n)==true)
    {
        for(int i=0;i<n;i++)
            cout<<0<<" ";
    }
    else if(check1(a,n)==true)
    {
        for(int i=0;i<n-1;i++)
            cout<<a[n-1]+1-a[i]<<" ";
        cout<<0;
    }
    else
        hehe(a,0,n-1,n);

}


#include<bits/stdc++.h>
using namespace std;

map<int,int> ma;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        ma[-a[i]]++;
    }

    map<int,int> :: iterator it;
    it=ma.begin();

    for(int i=0;i<n;i++)
    {
        if(a[i]!=-(*it).first)
        {
            cout<<-(*it).first+1-a[i]<<" ";
            ma[-a[i]]--;
        }
        else if(a[i]==-(*it).first && (*it).second==1)
        {
            cout<<0<<" ";
            ma[-a[i]]--;
            while((*it).second==0 && i!=n-1)
                it++;
        }
        else if(a[i]==-(*it).first && (*it).second>1)
        {
            cout<<1<<" ";
            ma[-a[i]]--;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;

void hehe(int a[],int left,int right,int n)
{
    //int i=left,j=right;
    int lon=0,vt=0;
    for(int k=left;k<=right;k++)
    {
        if(lon<=a[k])
        {
            lon=a[k];
            vt=k;
        }
    }

    for(int i=left;i<=vt;i++)
    {
        if(i!=vt)
            cout<<lon+1-a[i]<<" ";
        else
            cout<<0<<" ";
    }

    if(vt!=n-1)
        hehe(a,vt+1,n-1,n);

}
bool check(int a[],int n)
{
    for(int i=0;i<n-1;i++)
    {
        if(a[i]<=a[i+1])
            return false;
    }
    return true;
}

int main()
{
    int n;
    cin>>n;
    int a[n];
    //int lon=0,vt=0;
    for(int i=0;i<n;i++)
        cin>>a[i];

    if(check(a,n)==true)
    {
        for(int i=0;i<n;i++)
            cout<<0<<" ";
    }
    else
        hehe(a,0,n-1,n);

}


#include<bits/stdc++.h>
using namespace std;

void hehe(int a[],int left,int right,int n)
{
    //int i=left,j=right;
    int lon=0,vt=0;
    for(int k=left;k<=right;k++)
    {
        if(lon<=a[k])
        {
            lon=a[k];
            vt=k;
        }
    }

    for(int i=left;i<=vt;i++)
    {
        if(i!=vt)
            cout<<lon+1-a[i]<<" ";
        else
            cout<<0<<" ";
    }

    if(vt!=n-1)
        hehe(a,vt+1,n-1,n);

}

int main()
{
    int n;
    cin>>n;
    int a[n];
    //int lon=0,vt=0;
    for(int i=0;i<n;i++)
        cin>>a[i];

    hehe(a,0,n-1,n);

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

int main()
{
    ll n,mx,j,i;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }

    if(n==1)
    {
        cout<<"0"<<endl;
    }
    if(n==2)
    {
        if(arr[0]<arr[1])
        {
            cout<<arr[1]-arr[0]+1<<" "<<"0"<<endl;
        }
        else
        {
            cout<<"0"<<" "<<"0"<<endl;
        }
        exit(0);
    }
    mx = arr[n-1];
    arr[n-1]=0;
   for(i=n-2;i>=0;i--)
   {
       if(arr[i]>mx)
       {
           mx=arr[i];
           arr[i]=0;
       }
       else
       {
           arr[i]=mx-arr[i]+1;
       }
   }
   for(i=0;i<n;i++)
   {
       cout<<arr[i]<<" ";
   }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

int main()
{
    ll n,mx,j,i;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    for(i=0;i<n;i++)
    {
        mx=0;
        for(j=i+1;j<n;j++)
        {
            if(arr[j]>mx)
            {
                mx=arr[j];
            }
        }
        if(mx>arr[i])
        {
            arr[i]=mx-arr[i]+1;
        }
        else
        {
            arr[i]=0;
        }
    }

    for(i=0;i<n;i++)
    {
        cout<<arr[i]<<" ";
    }
    cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

int main()
{
    ll n,mx,j,i;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }

    if(n==1)
    {
        cout<<"0"<<endl;
    }
    if(n==2)
    {
        if(arr[0]<arr[1])
        {
            cout<<arr[1]-arr[0]+1<<" "<<"0"<<endl;
        }
        else
        {
            cout<<"0"<<" "<<"0"<<endl;
        }
    }
    mx = arr[n-1];
    arr[n-1]=0;
   for(i=n-2;i>=0;i--)
   {
       if(arr[i]>mx)
       {
           mx=arr[i];
           arr[i]=0;
       }
       else
       {
           arr[i]=mx-arr[i]+1;
       }
   }
   for(i=0;i<n;i++)
   {
       cout<<arr[i]<<" ";
   }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

int main()
{
    ll n,mx,j,i;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }

    if(n==1)
    {
        cout<<arr[0]<<endl;
    }
    mx = arr[n-1];
    arr[n-1]=0;
   for(i=n-2;i>=0;i--)
   {
       if(arr[i]>mx)
       {
           mx=arr[i];
           arr[i]=0;
       }
       else
       {
           arr[i]=mx-arr[i]+1;
       }
   }
   for(i=0;i<n;i++)
   {
       cout<<arr[i]<<" ";
   }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

int main()
{
    ll n,mx,j,i;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }

    if(n==1)
    {
        cout<<"0"<<endl;
        exit(0);
    }
    if(n==2)
    {
        if(arr[0]<arr[1])
        {
            cout<<arr[1]-arr[0]+1<<" "<<"0"<<endl;
        }
        else
        {
            cout<<"0"<<" "<<"0"<<endl;
        }
        exit(0);
    }
    mx = arr[n-1];
    arr[n-1]=0;
   for(i=n-2;i>=0;i--)
   {
       if(arr[i]>mx)
       {
           mx=arr[i];
           arr[i]=0;
       }
       else
       {
           arr[i]=mx-arr[i]+1;
       }
   }
   for(i=0;i<n;i++)
   {
       cout<<arr[i]<<" ";
   }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

int main()
{
    ll n,mx,j,i;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }

    if(n==1)
    {
        cout<<"0"<<endl;
    }
    if(n==2)
    {
        if(arr[0]<arr[1])
        {
            cout<<arr[1]-arr[0]+1<<" "<<"0"<<endl;
        }
        else
        {
            cout<<"0"<<" "<<"0"<<endl;
        }
    }
    mx = arr[n-1];
    arr[n-1]=0;
   for(i=n-2;i>=0;i--)
   {
       if(arr[i]>mx)
       {
           mx=arr[i];
           arr[i]=0;
       }
       else
       {
           arr[i]=mx-arr[i]+1;
       }
       exit(0);
   }
   for(i=0;i<n;i++)
   {
       cout<<arr[i]<<" ";
   }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

int main()
{
    ll n,mx,j,i;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }

    if(n==1)
    {
        cout<<arr[0]<<endl;a
    }
    mx = arr[n-1];
    arr[n-1]=0;
   for(i=n-2;i>=0;i--)
   {
       if(arr[i]>mx)
       {
           mx=arr[i];
           arr[i]=0;
       }
       else
       {
           arr[i]=mx-arr[i]+1;
       }
   }
   for(i=0;i<n;i++)
   {
       cout<<arr[i]<<" ";
   }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

int main()
{
    ll n,mx,j,i;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }

    if(n==1)
    {
        cout<<"0"<<endl;
        exit(0);
    }
    if(n==2)
    {
        if(arr[0]<=arr[1])
        {
            cout<<arr[1]-arr[0]+1<<" "<<"0"<<endl;
        }
        else
        {
            cout<<"0"<<" "<<"0"<<endl;
        }
        exit(0);
    }
    mx = arr[n-1];
    arr[n-1]=0;
   for(i=n-2;i>=0;i--)
   {
       if(arr[i]>mx)
       {
           mx=arr[i];
           arr[i]=0;
       }
       else
       {
           arr[i]=mx-arr[i]+1;
       }
   }
   for(i=0;i<n;i++)
   {
       cout<<arr[i]<<" ";
   }
}


#include <iostream>
#define int long long
#define mod 1000003
using namespace std;
int inv[1100000];
int a[20][20],b[20];
signed main(int argc, char** argv) {
	int n=10;
	inv[1]=1;
	for(int i=2;i<mod;i++)
		inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(int i=0;i<=n;i++)
	{
		a[i][0]=1;
		for(int j=1;j<=n;j++)
			a[i][j]=a[i][j-1]*i%mod;
		cout << "? " << i << endl;
		cin >> a[i][n+1];
		for(int j=0;j<i;j++)
		{
			int t=a[j][j]*inv[a[i][j]]%mod;
			for(int k=0;k<=n+1;k++)
				a[i][k]=a[i][k]*t%mod,a[i][k]=(a[i][k]+mod-a[j][k])%mod;
		}
	}
	for(int i=n;i>=0;i--)
	{
		for(int j=n;j>i;j++)
		{
			a[i][n+1]=(a[i][n+1]-a[i][j]*b[j])%mod;
			a[i][n+1]=(a[i][n+1]+mod)%mod;
			if(i==n-1)
			return a[i][i];
		}
		b[i]=(a[i][n+1]*inv[a[i][i]])%mod;
	}
	for(int i=0;i<1000003;i++)
	{
		int p=1,now=0;
		for(int j=0;j<=n;j++)
		{
			now=(now+p*b[j])%mod;
			p=p*i%mod;
		}
		if(!now)
		{
			cout << "! " << i << endl;
			return 0;
		}
	}
	cout << "-1" << endl;
	return 0;
}


#include <iostream>
#define int long long
#define mod 1000003
using namespace std;
int inv[1100000];
int a[20][20],b[20];
signed main(int argc, char** argv) {
	int n=10;
	inv[1]=1;
	for(int i=2;i<mod;i++)
		inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(int i=0;i<=n;i++)
	{
		a[i][0]=1;
		for(int j=1;j<=n;j++)
			a[i][j]=a[i][j-1]*i%mod;
		cout << "? " << i << endl;
		cin >> a[i][n+1];
		for(int j=0;j<i;j++)
		{
			int t=a[j][j]*inv[a[i][j]]%mod;
			for(int k=0;k<=n+1;k++)
				a[i][k]=a[i][k]*t%mod,a[i][k]=(a[i][k]+mod-a[j][k])%mod;
		}
	}
	for(int i=n;i>=0;i--)
	{
		for(int j=n;j>i;j++)
		{
			a[i][n+1]=(a[i][n+1]-a[i][j]*b[j])%mod;
			a[i][n+1]=(a[i][n+1]+mod)%mod;
		}
		if(a[i][i]>=mod) return a[i][i];
		b[i]=(a[i][n+1]*inv[a[i][i]])%mod;
	}
	for(int i=0;i<1000003;i++)
	{
		int p=1,now=0;
		for(int j=0;j<=n;j++)
		{
			now=(now+p*b[j])%mod;
			p=p*i%mod;
		}
		if(!now)
		{
			cout << "! " << i << endl;
			return 0;
		}
	}
	cout << "-1" << endl;
	return 0;
}


#include <iostream>
#define int long long
#define mod 1000003
using namespace std;
int inv[1100000];
int a[20][20],b[20];
signed main(int argc, char** argv) {
	int n=10;
	inv[1]=1;
	for(int i=2;i<mod;i++)
		inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(int i=0;i<=n;i++)
	{
		a[i][0]=1;
		for(int j=1;j<=n;j++)
			a[i][j]=a[i][j-1]*i%mod;
		cout << "? " << i << endl;
		cin >> a[i][n+1];
		for(int j=0;j<i;j++)
		{
			int t=a[j][j]*inv[a[i][j]]%mod;
			for(int k=0;k<=n+1;k++)
				a[i][k]=a[i][k]*t%mod,a[i][k]=(a[i][k]+mod-a[j][k])%mod;
		}
	}
	for(int i=n;i>=0;i--)
	{
		for(int j=n;j>i;j--)
		{
			a[i][n+1]=(a[i][n+1]-a[i][j]*b[j])%mod;
			a[i][n+1]=(a[i][n+1]+mod)%mod;
		}
		b[i]=(a[i][n+1]*inv[a[i][i]])%mod;
	}
	for(int i=0;i<1000003;i++)
	{
		int p=1,now=0;
		for(int j=0;j<=n;j++)
		{
			now=(now+p*b[j])%mod;
			p=p*i%mod;
		}
		if(!now)
		{
			cout << "! " << i << endl;
			return 0;
		}
	}
	cout << "! "<< "-1" << endl;
	return 0;
}


#include <iostream>
#define int long long
#define mod 1000003
using namespace std;
int inv[1100000];
int a[20][20],b[20];
signed main(int argc, char** argv) {
	int n=10;
	inv[1]=1;
	for(int i=2;i<mod;i++)
		inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(int i=0;i<=n;i++)
	{
		a[i][0]=1;
		for(int j=1;j<=n;j++)
			a[i][j]=a[i][j-1]*i%mod;
		cout << "? " << i << endl;
		cin >> a[i][n+1];
		for(int j=0;j<i;j++)
		{
			int t=a[j][j]*inv[a[i][j]]%mod;
			for(int k=0;k<=n+1;k++)
				a[i][k]=a[i][k]*t%mod,a[i][k]=(a[i][k]+mod-a[j][k])%mod;
		}
	}
	for(int i=n;i>=0;i--)
	{
		for(int j=n;j>i;j++)
		{
			a[i][n+1]=(a[i][n+1]-a[i][j]*b[j])%mod;
			a[i][n+1]=(a[i][n+1]+mod)%mod;
		}
			if(i==n-1)
			return a[i][i];
		b[i]=(a[i][n+1]*inv[a[i][i]])%mod;
	}
	for(int i=0;i<1000003;i++)
	{
		int p=1,now=0;
		for(int j=0;j<=n;j++)
		{
			now=(now+p*b[j])%mod;
			p=p*i%mod;
		}
		if(!now)
		{
			cout << "! " << i << endl;
			return 0;
		}
	}
	cout << "-1" << endl;
	return 0;
}


#include <iostream>
#define int long long
#define mod 1000003
using namespace std;
int inv[1100000];
int a[20][20],b[20];
signed main(int argc, char** argv) {
	int n=10;
	inv[1]=1;
	for(int i=2;i<mod;i++)
		inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(int i=0;i<=n;i++)
	{
		a[i][0]=1;
		for(int j=1;j<=n;j++)
			a[i][j]=a[i][j-1]*i%mod;
		cout << "? " << i << endl;
		cin >> a[i][n+1];
		for(int j=0;j<i;j++)
		{
			int t=a[j][j]*inv[a[i][j]]%mod;
			for(int k=0;k<=n+1;k++)
				a[i][k]=a[i][k]*t%mod,a[i][k]=(a[i][k]+mod-a[j][k])%mod;
		}
	}
	for(int i=n;i>=0;i--)
	{
		for(int j=n;j>i;j++)
		{
			a[i][n+1]=(a[i][n+1]-a[i][j]*b[j])%mod;
			a[i][n+1]=(a[i][n+1]+mod)%mod;
		}
		b[i]=(a[i][n+1]*inv[a[i][i]])%mod;
		return 0;
	}
	for(int i=0;i<1000003;i++)
	{
		int p=1,now=0;
		for(int j=0;j<=n;j++)
		{
			now=(now+p*b[j])%mod;
			p=p*i%mod;
		}
		if(!now)
		{
			cout << "! " << i << endl;
			return 0;
		}
	}
	cout << "-1" << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000003;
const ll D = 100;

ll fp(ll x,ll y){
    ll ans = 1;
    for(;y;y>>=1,x = (x*x)%mod){
        if(y&1){
            ans = (ans*x)%mod;
        }
    }
    return ans;
}
ll inv(ll x){
    return fp(x,mod-2);
}

struct Matrix{
    ll n,m,a[D][D],s;
    Matrix (int a = 0,int b = 0): n(a),m(b),s(0){}
    void gauss(){
        for(int i = 1; i <= min(m,n); i++){
            bool zam = 0;
            for(int j = i; j <= n; j++){
                if(a[j][i]){
                    if(j != i){
                        for(int k = i; k <= m; k++){
                            swap(a[i][k],a[j][k]);
                        }
                        s++;
                    }
                    zam = 1;
                    break;
                }
            }
            if(!zam){
                break;
            }
            for(int j = i+1; j <= n; j++){
                ll pom = ((mod - a[j][i])*inv(a[i][i]))%mod;
                for(int k = i; k <= m; k++){
                    a[j][k] += (a[i][k]*pom)%mod;
                    a[j][k] %= mod;
                }
            }
        }
    }
    ll det(){
        if(n != m){
            return 0;
        }
        gauss();
        ll ans = (s&1)?(mod-1):1;
        for(int i = 1; i <= n; i++){
            ans *= a[i][i];
            ans %= mod;
        }
        return ans;
    }
    void resi(ll b[]){
        gauss();
        for(int i = 1; i <= min(n,m-1); i++){
            if(!a[i][i]){
                return;
            }
        }
        for(int i = min(n,m-1); i >= 1; i--){
            b[i] = a[i][m];
            for(int j = i+1; j < m; j++){
                b[i] -= (a[i][j]*b[j])%mod;
                if(b[i] < 0){
                    b[i] += mod;
                }
            }
            b[i] = (b[i]*inv(a[i][i]))%mod;
        }
    }
};
Matrix operator * (Matrix a,Matrix b){
    Matrix ans;
    for(int i = 0; i < D; i++){
        for(int j = 0; j < D; j++){
            ans.a[i][j] = 0;
            for(int k = 0; k < D; k++){
                ans.a[i][j] += a.a[i][k]*b.a[k][j];
                ans.a[i][j] %= mod;
            }
        }
    }
    return ans;
}
Matrix mpow(Matrix a,ll k){
    Matrix ans;
    for(long i = 0; i < D; i++){
        ans.a[i][i] = 1;
    }
    while(k){
        if(k&1){
            ans = ans*a;
        }
        a = a*a;
        k >>= 1;
    }
    return ans;
}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
ll p[D];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    Matrix mat;
    mat.n = 12;
    mat.m = 12;
    for(int i = 1; i <= 12; i++){
        ll x = rnd()%mod;
        cout << "? " << x << endl;
        ll ans;
        cin >> ans;
        if(ans == 0){
            cout << "! " << x << endl;
            return 0;
        }
        mat.a[i][12] = ans;
        for(int j = 1; j <= 11; j++){
            mat.a[i][j] = fp(x,j-1);
        }
    }
    mat.resi(p);
    for(int i = 0; i < mod; i++){
        ll val = 0,pw = 1;
        for(int j = 1; j <= 11; j++){
            val += (pw*p[j])%mod;
            if(val >= mod){
                val -= mod;
            }
            pw = (pw*i)%mod;
        }
        if(val == 0){
            cout << "! " << i << endl;
            return 0;
        }
    }
    cout << "! -1" << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000003;
const ll D = 100;

ll fp(ll x,ll y){
    ll ans = 1;
    for(;y;y>>=1,x = (x*x)%mod){
        if(y&1){
            ans = (ans*x)%mod;
        }
    }
    return ans;
}
ll inv(ll x){
    return fp(x,mod-2);
}

struct Matrix{
    ll n,m,a[D][D],s;
    Matrix (int a = 0,int b = 0): n(a),m(b),s(0){}
    void gauss(){
        for(int i = 1; i <= min(m,n); i++){
            bool zam = 0;
            for(int j = i; j <= n; j++){
                if(a[j][i]){
                    if(j != i){
                        for(int k = i; k <= m; k++){
                            swap(a[i][k],a[j][k]);
                        }
                        s++;
                    }
                    zam = 1;
                    break;
                }
            }
            if(!zam){
                break;
            }
            for(int j = i+1; j <= n; j++){
                ll pom = ((mod - a[j][i])*inv(a[i][i]))%mod;
                cout << pom << " ";
                for(int k = i; k <= m; k++){
                    a[j][k] += (a[i][k]*pom)%mod;
                    a[j][k] %= mod;
                }
            }
        }
    }
    ll det(){
        if(n != m){
            return 0;
        }
        gauss();
        ll ans = (s&1)?(mod-1):1;
        for(int i = 1; i <= n; i++){
            ans *= a[i][i];
            ans %= mod;
        }
        return ans;
    }
    void resi(ll b[]){
        gauss();
        for(int i = 1; i <= min(n,m-1); i++){
            if(!a[i][i]){
                return;
            }
        }
        for(int i = min(n,m-1); i >= 1; i--){
            b[i] = a[i][m];
            for(int j = i+1; j < m; j++){
                b[i] -= (a[i][j]*b[j])%mod;
                if(b[i] < 0){
                    b[i] += mod;
                }
            }
            b[i] = (b[i]*inv(a[i][i]))%mod;
        }
    }
};
Matrix operator * (Matrix a,Matrix b){
    Matrix ans;
    for(int i = 0; i < D; i++){
        for(int j = 0; j < D; j++){
            ans.a[i][j] = 0;
            for(int k = 0; k < D; k++){
                ans.a[i][j] += a.a[i][k]*b.a[k][j];
                ans.a[i][j] %= mod;
            }
        }
    }
    return ans;
}
Matrix mpow(Matrix a,ll k){
    Matrix ans;
    for(long i = 0; i < D; i++){
        ans.a[i][i] = 1;
    }
    while(k){
        if(k&1){
            ans = ans*a;
        }
        a = a*a;
        k >>= 1;
    }
    return ans;
}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
ll p[D];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    Matrix mat;
    mat.n = 50;
    mat.m = 12;
    for(int i = 1; i <= 50; i++){
        ll x = rnd()%mod;
        cout << x << endl;
        ll ans;
        cin >> ans;
        if(ans == 0){
            cout << "! " << x << endl;
            return 0;
        }
        mat.a[i][12] = ans;
        for(int j = 1; j <= 11; j++){
            mat.a[i][j] = fp(x,j-1);
        }
    }
    mat.resi(p);
    for(int i = 0; i < mod; i++){
        ll val = 0,pw = 1;
        for(int j = 1; j <= 11; j++){
            val += (pw*p[j])%mod;
            if(val >= mod){
                val -= mod;
            }
            pw = (pw*i)%mod;
        }
        if(val == 0){
            cout << "! " << i << endl;
            return 0;
        }
    }
    cout << "! -1" << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000003;
const ll D = 100;

ll fp(ll x,ll y){
    ll ans = 1;
    for(;y;y>>=1,x = (x*x)%mod){
        if(y&1){
            ans = (ans*x)%mod;
        }
    }
    return ans;
}
ll inv(ll x){
    return fp(x,mod-2);
}

struct Matrix{
    ll n,m,a[D][D],s;
    Matrix (int a = 0,int b = 0): n(a),m(b),s(0){}
    void gauss(){
        for(int i = 1; i <= min(m,n); i++){
            bool zam = 0;
            for(int j = i; j <= n; j++){
                if(a[j][i]){
                    if(j != i){
                        for(int k = i; k <= m; k++){
                            swap(a[i][k],a[j][k]);
                        }
                        s++;
                    }
                    zam = 1;
                    break;
                }
            }
            if(!zam){
                break;
            }
            for(int j = i+1; j <= n; j++){
                ll pom = ((mod - a[j][i])*inv(a[i][i]))%mod;
                cout << pom << " ";
                for(int k = i; k <= m; k++){
                    a[j][k] += (a[i][k]*pom)%mod;
                    a[j][k] %= mod;
                }
            }
        }
    }
    ll det(){
        if(n != m){
            return 0;
        }
        gauss();
        ll ans = (s&1)?(mod-1):1;
        for(int i = 1; i <= n; i++){
            ans *= a[i][i];
            ans %= mod;
        }
        return ans;
    }
    void resi(ll b[]){
        gauss();
        for(int i = 1; i <= min(n,m-1); i++){
            if(!a[i][i]){
                return;
            }
        }
        for(int i = min(n,m-1); i >= 1; i--){
            b[i] = a[i][m];
            for(int j = i+1; j < m; j++){
                b[i] -= (a[i][j]*b[j])%mod;
                if(b[i] < 0){
                    b[i] += mod;
                }
            }
            b[i] = (b[i]*inv(a[i][i]))%mod;
        }
    }
};
Matrix operator * (Matrix a,Matrix b){
    Matrix ans;
    for(int i = 0; i < D; i++){
        for(int j = 0; j < D; j++){
            ans.a[i][j] = 0;
            for(int k = 0; k < D; k++){
                ans.a[i][j] += a.a[i][k]*b.a[k][j];
                ans.a[i][j] %= mod;
            }
        }
    }
    return ans;
}
Matrix mpow(Matrix a,ll k){
    Matrix ans;
    for(long i = 0; i < D; i++){
        ans.a[i][i] = 1;
    }
    while(k){
        if(k&1){
            ans = ans*a;
        }
        a = a*a;
        k >>= 1;
    }
    return ans;
}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
ll p[D];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    Matrix mat;
    mat.n = 50;
    mat.m = 12;
    for(int i = 1; i <= 50; i++){
        ll x = rnd()%mod;
        cout << "? " << x << endl;
        ll ans;
        cin >> ans;
        if(ans == 0){
            cout << "! " << x << endl;
            return 0;
        }
        mat.a[i][12] = ans;
        for(int j = 1; j <= 11; j++){
            mat.a[i][j] = fp(x,j-1);
        }
    }
    mat.resi(p);
    for(int i = 0; i < mod; i++){
        ll val = 0,pw = 1;
        for(int j = 1; j <= 11; j++){
            val += (pw*p[j])%mod;
            if(val >= mod){
                val -= mod;
            }
            pw = (pw*i)%mod;
        }
        if(val == 0){
            cout << "! " << i << endl;
            return 0;
        }
    }
    cout << "! -1" << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000003;
const ll D = 100;

ll fp(ll x,ll y){
    ll ans = 1;
    for(;y;y>>=1,x = (x*x)%mod){
        if(y&1){
            ans = (ans*x)%mod;
        }
    }
    return ans;
}
ll inv(ll x){
    return fp(x,mod-2);
}

struct Matrix{
    ll n,m,a[D][D],s;
    Matrix (int a = 0,int b = 0): n(a),m(b),s(0){}
    void gauss(){
        for(int i = 1; i <= min(m,n); i++){
            bool zam = 0;
            for(int j = i; j <= n; j++){
                if(a[j][i]){
                    if(j != i){
                        for(int k = i; k <= m; k++){
                            swap(a[i][k],a[j][k]);
                        }
                        s++;
                    }
                    zam = 1;
                    break;
                }
            }
            if(!zam){
                break;
            }
            for(int j = i+1; j <= n; j++){
                ll pom = ((mod - a[j][i])*inv(a[i][i]))%mod;
                for(int k = i; k <= m; k++){
                    a[j][k] += (a[i][k]*pom)%mod;
                    a[j][k] %= mod;
                }
            }
        }
    }
    ll det(){
        if(n != m){
            return 0;
        }
        gauss();
        ll ans = (s&1)?(mod-1):1;
        for(int i = 1; i <= n; i++){
            ans *= a[i][i];
            ans %= mod;
        }
        return ans;
    }
    void resi(ll b[]){
        gauss();
        for(int i = 1; i <= min(n,m-1); i++){
            if(!a[i][i]){
                return;
            }
        }
        for(int i = min(n,m-1); i >= 1; i--){
            b[i] = a[i][m];
            for(int j = i+1; j < m; j++){
                b[i] -= (a[i][j]*b[j])%mod;
                if(b[i] < 0){
                    b[i] += mod;
                }
            }
            b[i] = (b[i]*inv(a[i][i]))%mod;
        }
    }
};
Matrix operator * (Matrix a,Matrix b){
    Matrix ans;
    for(int i = 0; i < D; i++){
        for(int j = 0; j < D; j++){
            ans.a[i][j] = 0;
            for(int k = 0; k < D; k++){
                ans.a[i][j] += a.a[i][k]*b.a[k][j];
                ans.a[i][j] %= mod;
            }
        }
    }
    return ans;
}
Matrix mpow(Matrix a,ll k){
    Matrix ans;
    for(long i = 0; i < D; i++){
        ans.a[i][i] = 1;
    }
    while(k){
        if(k&1){
            ans = ans*a;
        }
        a = a*a;
        k >>= 1;
    }
    return ans;
}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
ll p[D];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    Matrix mat;
    mat.n = 50;
    mat.m = 12;
    for(int i = 1; i <= 50; i++){
        ll x = rnd()%mod;
        cout << "? " << x << endl;
        ll ans;
        cin >> ans;
        if(ans == 0){
            cout << "! " << x << endl;
            return 0;
        }
        mat.a[i][12] = ans;
        for(int j = 1; j <= 11; j++){
            mat.a[i][j] = fp(x,j-1);
        }
    }
    mat.resi(p);
    for(int i = 0; i < mod; i++){
        ll val = 0,pw = 1;
        for(int j = 1; j <= 11; j++){
            val += (pw*p[j])%mod;
            if(val >= mod){
                val -= mod;
            }
            pw = (pw*i)%mod;
        }
        if(val == 0){
            cout << "! " << i << endl;
            return 0;
        }
    }
    cout << "! -1" << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef int ll;
const ll mod = 1000003;
const ll D = 100;

ll fp(ll x,ll y){
    ll ans;
    for(;y;y>>=1,x = (x*x)%mod){
        if(y&1){
            ans = (ans*x)%mod;
        }
    }
    return ans;
}
ll inv(ll x){
    return fp(x,mod-2);
}

struct Matrix{
    ll n,m,a[D][D],s;
    Matrix (int a = 0,int b = 0): n(a),m(b),s(0){}
    void gauss(){
        for(int i = 1; i <= min(m,n); i++){
            bool zam = 0;
            for(int j = i; j <= n; j++){
                if(a[j][i]){
                    if(j != i){
                        for(int k = i; k <= m; k++){
                            swap(a[i][k],a[j][k]);
                        }
                    }
                    s++;
                    zam = 1;
                    break;
                }
            }
            if(!zam){
                break;
            }
            for(int j = i+1; j <= n; j++){
                for(int k = m; k >= i; k--){
                    ll pom = ((mod - a[j][i])*inv(a[i][i]))%mod;
                    a[j][k] += (a[i][k]*pom)%mod;
                    a[j][k] %= mod;
                }
            }
        }
    }
    ll det(){
        if(n != m){
            return 0;
        }
        gauss();
        ll ans = (s&1)?(mod-1):1;
        for(int i = 1; i <= n; i++){
            ans *= a[i][i];
            ans %= mod;
        }
        return ans;
    }
    void resi(ll b[]){
        gauss();
        for(int i = 1; i <= min(n,m-1); i++){
            if(!a[i][i]){
                return;
            }
        }
        for(int i = min(n,m-1); i >= 1; i--){
            b[i] = a[i][m];
            for(int j = i+1; j < m; j++){
                b[i] -= (a[i][j]*b[j])%mod;
                if(b[i] < 0){
                    b[i] += mod;
                }
            }
            b[i] = (b[i]*inv(a[i][i]))%mod;
        }
    }
};
Matrix operator * (Matrix a,Matrix b){
    Matrix ans;
    for(int i = 0; i < D; i++){
        for(int j = 0; j < D; j++){
            ans.a[i][j] = 0;
            for(int k = 0; k < D; k++){
                ans.a[i][j] += a.a[i][k]*b.a[k][j];
                ans.a[i][j] %= mod;
            }
        }
    }
    return ans;
}
Matrix mpow(Matrix a,ll k){
    Matrix ans;
    for(long i = 0; i < D; i++){
        ans.a[i][i] = 1;
    }
    while(k){
        if(k&1){
            ans = ans*a;
        }
        a = a*a;
        k >>= 1;
    }
    return ans;
}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
ll p[D];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    Matrix mat;
    mat.n = 50;
    mat.m = 12;
    for(int i = 1; i <= 50; i++){
        ll x = rnd()%mod;
        cout << x << endl;
        ll ans;
        cin >> ans;
        if(ans == 0){
            cout << "! " << x << endl;
            return 0;
        }
        mat.a[i][12] = ans;
        for(int j = 1; j <= 11; j++){
            mat.a[i][j] = fp(x,j-1);
        }
    }
    mat.resi(p);
    for(int i = 0; i < mod; i++){
        ll val = 0,pw = 1;
        for(int j = 1; j <= 11; j++){
            val += (pw*p[j])%mod;
            if(val >= mod){
                val -= mod;
            }
            pw = (pw*i)%mod;
        }
        if(val == 0){
            cout << "! " << i << endl;
            return 0;
        }
    }
    cout << "! -1" << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000003;
const ll D = 100;

ll fp(ll x,ll y){
    ll ans;
    for(;y;y>>=1,x = (x*x)%mod){
        if(y&1){
            ans = (ans*x)%mod;
        }
    }
    return ans;
}
ll inv(ll x){
    return fp(x,mod-2);
}

struct Matrix{
    ll n,m,a[D][D],s;
    Matrix (int a = 0,int b = 0): n(a),m(b),s(0){}
    void gauss(){
        for(int i = 1; i <= min(m,n); i++){
            bool zam = 0;
            for(int j = i; j <= n; j++){
                if(a[j][i]){
                    if(j != i){
                        for(int k = i; k <= m; k++){
                            swap(a[i][k],a[j][k]);
                        }
                    }
                    s++;
                    zam = 1;
                    break;
                }
            }
            if(!zam){
                break;
            }
            for(int j = i+1; j <= n; j++){
                for(int k = m; k >= i; k--){
                    ll pom = ((mod - a[j][i])*inv(a[i][i]))%mod;
                    a[j][k] += (a[i][k]*pom)%mod;
                    a[j][k] %= mod;
                }
            }
        }
    }
    ll det(){
        if(n != m){
            return 0;
        }
        gauss();
        ll ans = (s&1)?(mod-1):1;
        for(int i = 1; i <= n; i++){
            ans *= a[i][i];
            ans %= mod;
        }
        return ans;
    }
    void resi(ll b[]){
        gauss();
        for(int i = 1; i <= min(n,m-1); i++){
            if(!a[i][i]){
                return;
            }
        }
        for(int i = min(n,m-1); i >= 1; i--){
            b[i] = a[i][m];
            for(int j = i+1; j < m; j++){
                b[i] -= (a[i][j]*b[j])%mod;
                if(b[i] < 0){
                    b[i] += mod;
                }
            }
            b[i] = (b[i]*inv(a[i][i]))%mod;
        }
    }
};
Matrix operator * (Matrix a,Matrix b){
    Matrix ans;
    for(int i = 0; i < D; i++){
        for(int j = 0; j < D; j++){
            ans.a[i][j] = 0;
            for(int k = 0; k < D; k++){
                ans.a[i][j] += a.a[i][k]*b.a[k][j];
                ans.a[i][j] %= mod;
            }
        }
    }
    return ans;
}
Matrix mpow(Matrix a,ll k){
    Matrix ans;
    for(long i = 0; i < D; i++){
        ans.a[i][i] = 1;
    }
    while(k){
        if(k&1){
            ans = ans*a;
        }
        a = a*a;
        k >>= 1;
    }
    return ans;
}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
ll p[D];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    Matrix mat;
    mat.n = 50;
    mat.m = 12;
    for(int i = 1; i <= 50; i++){
        ll x = rnd()%mod;
        cout << x << endl;
        ll ans;
        cin >> ans;
        if(ans == 0){
            cout << "! " << x << endl;
            return 0;
        }
        mat.a[i][12] = ans;
        for(int j = 1; j <= 11; j++){
            mat.a[i][j] = fp(x,j-1);
        }
    }
    mat.resi(p);
    for(int i = 0; i < mod; i++){
        ll val = 0,pw = 1;
        for(int j = 1; j <= 11; j++){
            val += (pw*p[j])%mod;
            if(val >= mod){
                val -= mod;
            }
            pw = (pw*i)%mod;
        }
        if(val == 0){
            cout << "! " << i << endl;
            return 0;
        }
    }
    cout << "! -1" << endl;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl '\n'
#define int ll
#define mod 1000003
using namespace std;

int pows(int a, int b)
{
	int ans = 1ll;
	a %= mod;
	while(b)
	{
		if(b & 1) ans = (ans * (a + 0ll) % mod);
		b >>= 1ll;
		a = (a * a) % mod;
	}
	return ans;
}
int32_t main()
{
    //ios_base::sync_with_stdio(false);
   // cin.tie(0); cout.tie(0);
    int n = 12;
    int x[13],y[13];
    for(int i = 1 ; i <= n ; i ++)
    {
		cout << "? " << i << endl;
		fflush(stdout);
		x[i] = i;
		cin >> y[i];
	}
	int f[13]{0};
	for(int i = 1 ; i <= n ; i ++)
	{
		int s2 = 1;
		for(int j = 1 ; j <= n ; j ++)
		{
			if(i != j) s2 = s2 * (x[i] - x[j]) % mod;
		}
		f[i] = pows(s2, mod - 2);
	}
	for(auto x : f) cout << x << " ";
	cout << endl;
	for(int k = 0 ; k < mod ; k ++)
	{
		int  ans = 0;
		for(int i = 1 ; i <= n ; i ++)
		{
			int s = y[i] % mod;
			for(int j = 1 ; j <= n ; j ++)
			{
				if(i != j) s = s * (k - x[j]) % mod;
			}
			ans += s * f[i] % mod;
		}
		if(ans == 0)
		{
			cout << "! " << k << endl;
			fflush(stdout);
			return 0;
		}
	}
	cout << "! " << -1 << endl;
    fflush(stdout);
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl '\n'
#define int ll
#define mod 1000003
using namespace std;

int pows(int a, int b)
{
	int ans = 1ll;
	a %= mod;
	while(b)
	{
		if(b & 1) ans = (ans * (a + 0ll) % mod);
		b >>= 1ll;
		a = (a * a) % mod;
	}
	return ans;
}
int32_t main()
{
    //ios_base::sync_with_stdio(false);
   // cin.tie(0); cout.tie(0);
    int n = 12;
    int x[13],y[13];
    for(int i = 1 ; i <= n ; i ++)
    {
		cout << "? " << i << endl;
		fflush(stdout);
		x[i] = i;
		cin >> y[i];
	}
	int f[13]{0};
	for(int i = 1 ; i <= n ; i ++)
	{
		int s2 = 1;
		for(int j = 1 ; j <= n ; j ++)
		{
			if(i != j) s2 = s2 * (x[i] - x[j]) % mod;
		}
		f[i] = pows(s2, mod - 2);
	}
	/*for(auto x : f) cout << x << " ";
	cout << endl;*/
	for(int k = 0 ; k < mod ; k ++)
	{
		int  ans = 0;
		for(int i = 1 ; i <= n ; i ++)
		{
			int s = y[i] % mod;
			for(int j = 1 ; j <= n ; j ++)
			{
				if(i != j) s = s * (k - x[j]) % mod;
			}
			ans += s * f[i] % mod;
		}
		if(ans == 0)
		{
			cout << "! " << k << endl;
			fflush(stdout);
			return 0;
		}
	}
	cout << "! " << -1 << endl;
    fflush(stdout);
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl '\n'
#define int ll
#define mod 1000003
using namespace std;

int pows(int a, int b)
{
	int ans = 1ll;
	a %= mod;
	while(b)
	{
		if(b & 1) ans = (ans * (a + 0ll) % mod);
		b >>= 1ll;
		a = (a * a) % mod;
	}
	return ans;
}
int32_t main()
{
    //ios_base::sync_with_stdio(false);
   // cin.tie(0); cout.tie(0);
    int n = 12;
    int x[13],y[13];
    for(int i = 1 ; i <= n ; i ++)
    {
		cout << "? " << i << endl;
		fflush(stdout);
		x[i] = i;
		cin >> y[i];
	}
	int f[13]{0};
	for(int i = 1 ; i <= n ; i ++)
	{
		int s2 = 1;
		for(int j = 1 ; j <= n ; j ++)
		{
			if(i != j) s2 = s2 * (x[i] - x[j]) % mod;
		}
		f[i] = pows(s2, mod - 2);
	}
	/*for(auto x : f) cout << x << " ";
	cout << endl;*/
	for(int k = 0 ; k < mod ; k ++)
	{
		int  ans = 0;
		for(int i = 1 ; i <= n ; i ++)
		{
			int s = y[i] % mod;
			for(int j = 1 ; j <= n ; j ++)
			{
				if(i != j) s = s * (k - x[j]) % mod;
			}
			ans = (ans + mod +  s * f[i]) % mod;
		}
		if(ans == 0)
		{
			cout << "! " << k << endl;
			fflush(stdout);
			return 0;
		}
	}
	cout << "! " << -1 << endl;
    fflush(stdout);
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl '\n'
#define mod 1000003
using namespace std;

int pows(int a, int b)
{
	int ans = 1;
	a %= mod;
	while(b)
	{
		if(b & 1) ans = (ans * (a + 0ll) % mod);
		b >>= 1;
		a = (a * a) % mod;
	}
	return ans;
}
int32_t main()
{
    //ios_base::sync_with_stdio(false);
   // cin.tie(0); cout.tie(0);
    int n = 12;
    int x[13],y[13];
    for(int i = 1 ; i <= n ; i ++)
    {
		cout << "? " << i << endl;
		fflush(stdout);
		x[i] = i;
		cin >> y[i];
	}
	int f[13];
	for(int i = 1 ; i <= n ; i ++)
	{
		int s2 = 1;
		for(int j = 1 ; j <= n ; j ++)
		{
			if(i != j) s2 = s2 * (x[i] - x[j]) % mod;
		}
		f[i] = pows(s2, mod - 2);
	}
	for(int k = 0 ; k < mod ; k ++)
	{
		int  ans = 0;
		for(int i = 1 ; i <= n ; i ++)
		{
			int s = y[i] % mod;
			for(int j = 1 ; j <= n ; j ++)
			{
				if(i != j) s = s * (k - x[j]) % mod;
			}
			ans += s * f[i] % mod;
		}
		if(ans == 0)
		{
			cout << "! " << k << endl;
			fflush(stdout);
			return 0;
		}
	}
	cout << "! " << -1 << endl;
    fflush(stdout);
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl '\n'
#define int ll
#define mod 1000003
using namespace std;

int pows(int a, int b)
{
	int ans = 1ll;
	a %= mod;
	while(b)
	{
		if(b & 1) ans = (ans * (a + 0ll) % mod);
		b >>= 1ll;
		a = (a * a) % mod;
	}
	return ans;
}
int32_t main()
{
    //ios_base::sync_with_stdio(false);
   // cin.tie(0); cout.tie(0);
    int n = 12;
    int x[13],y[13];
    for(int i = 1 ; i <= n ; i ++)
    {
		cout << "? " << i << endl;
		fflush(stdout);
		x[i] = i;
		cin >> y[i];
	}
	int f[13]{0};
	for(int i = 1 ; i <= n ; i ++)
	{
		int s2 = 1;
		for(int j = 1 ; j <= n ; j ++)
		{
			if(i != j) s2 = s2 * (x[i] - x[j]) % mod;
		}
		f[i] = pows(s2, mod - 2);
	}
	/*for(auto x : f) cout << x << " ";
	cout << endl;*/
	for(int k = 0 ; k < mod ; k ++)
	{
		int  ans = 0;
		for(int i = 1 ; i <= n ; i ++)
		{
			int s = y[i] % mod;
			for(int j = 1 ; j <= n ; j ++)
			{
				if(i != j) s = s * (k - x[j]) % mod;
			}
			ans += (mod +  s * f[i]) % mod;
		}
		if(ans == 0)
		{
			cout << "! " << k << endl;
			fflush(stdout);
			return 0;
		}
	}
	cout << "! " << -1 << endl;
    fflush(stdout);
    return 0;
}


#include<bits/stdc++.h>
#define it register int
#define ct const int
#define il inline
using namespace std;
typedef long long ll;
#define rll register ll
#define cll const ll
const int N=1000005;
#define P 1000003
int inv[20],x[N],y[N],o;
il void que(ct x){printf("? %d\n",x),fflush(stdout),scanf("%d",&o);}
il int ksm(it x,it L){it ans=1;while(L) L&1?ans=(0ll+ans)*x%P:0,x=(0ll+x)*x%P,L>>=1;return ans;}
il void puo(ct x){printf("! %d\n",x),fflush(stdout);while(1);}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	it i,j,ans,tot;
	for(i=0;i<=10;++i){
		x[i]=i,que(i),y[i]=o;
		if(!o) return puo(i),0;
	}
	for(i=0;i<=10;++i)
		for(j=0,inv[i]=1;j<=10;++j)
			if(i^j) inv[i]=(0ll+inv[i])*ksm(x[j]-x[i],P-2)%P;
	for(it X=11;X<P;++X){
		for(i=0,tot=0;i<=10;++i){
			for(j=0,ans=(0ll+y[i])*inv[i]%P;j<=10;++j)
				if(i^j) ans=(0ll+ans)*(X-x[j])%P;
			tot+=ans,tot=(tot>=P?tot-P:tot);
		}
		if(!tot) return puo(X),0;
	}
	puo(-1);
	return 0;
}


#include<bits/stdc++.h>
#define it register int
#define ct const int
#define il inline
using namespace std;
typedef long long ll;
#define rll register ll
#define cll const ll
const int N=1000005;
#define P 1000003
int inv[20],x[N],y[N],o;
il void que(ct x){printf("? %d\n",x),fflush(stdout),scanf("%d",&o);}
il int ksm(it x,it L){it ans=1;while(L) L&1?ans=(0ll+ans)*x%P:0,x=(0ll+x)*x%P,L>>=1;return ans;}
il void puo(ct x){printf("! %d\n",x),fflush(stdout);}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	it i,j,ans,tot;
	for(i=0;i<=10;++i){
		x[i]=i,que(i),y[i]=o;
		if(!o) return puo(i),0;
	}
	for(i=0;i<=10;++i)
		for(j=0,inv[i]=1;j<=10;++j)
			if(i^j) inv[i]=(0ll+inv[i])*ksm(x[j]-x[i],P-2)%P;
	for(it X=11;X<P;++X){
		for(i=0,tot=0;i<=10;++i){
			for(j=0,ans=(0ll+y[i])*inv[i]%P;j<=10;++j)
				if(i^j) ans=(0ll+ans)*(X-x[j])%P;
			tot+=ans,tot=(tot>=P?tot-P:tot);
		}
		if(!tot) return puo(X),0;
	}
	puo(-1);
	return 0;
}


#include<bits/stdc++.h>
#define it register int
#define ct const int
#define il inline
using namespace std;
typedef long long ll;
#define rll register ll
#define cll const ll
const int N=1000005;
#define P 1000003
int inv[20],x[N],y[N],o;
il void que(ct x){printf("? %d\n",x),fflush(stdout),scanf("%d",&o);}
il int ksm(it x,it L){it ans=1;while(L) L&1?ans=(0ll+ans)*x%P:0,x=(0ll+x)*x%P,L>>=1;return ans;}
il void puo(ct x){printf("! %d\n",x),fflush(stdout);}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	it i,j,ans,tot;
	for(i=1;i<=10;++i){
		x[i]=i,que(i),y[i]=o;
		if(!o) return puo(i),0;
	}
	for(i=1;i<=10;++i)
		for(j=inv[i]=1;j<=10;++j)
			if(i^j) inv[i]=(0ll+inv[i])*ksm(x[i]-x[j],P-2)%P;
	for(it X=11;X<P;++X){
		for(i=1,tot=0;i<=10;++i){
			for(j=1,ans=(0ll+y[i])*inv[i]%P;j<=10;++j)
				if(i^j) ans=(0ll+ans)*(X-x[i])%P;
			tot+=ans,tot=(tot>=P?tot-P:tot);
		}
		if(!tot) return puo(X),0;
	}
	puo(-1);
	return 0;
}


#include<bits/stdc++.h>
#define it register int
#define ct const int
#define il inline
using namespace std;
typedef long long ll;
#define rll register ll
#define cll const ll
const int N=1000005;
#define P 1000003
int inv[20],x[N],y[N],o;
il void que(ct x){printf("? %d\n",x),fflush(stdout),scanf("%d",&o);}
il int ksm(it x,it L){it ans=1;while(L) L&1?ans=(0ll+ans)*x%P:0,x=(0ll+x)*x%P,L>>=1;return ans;}
il void puo(ct x){printf("! %d\n",x),fflush(stdout);}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	it i,j,ans,tot;
	for(i=0;i<=10;++i){
		x[i]=i,que(i),y[i]=o;
		if(!o) return puo(i),0;
	}
	for(i=0;i<=10;++i)
		for(j=0,inv[i]=1;j<=10;++j)
			if(i^j) inv[i]=(0ll+inv[i])*ksm(x[i]-x[j],P-2)%P;
	for(it X=11;X<P;++X){
		for(i=0,tot=0;i<=10;++i){
			for(j=0,ans=(0ll+y[i])*inv[i]%P;j<=10;++j)
				if(i^j) ans=(0ll+ans)*(X-x[j])%P;
			ans=(ans<0?ans+P:ans),tot+=ans,tot=(tot>=P?tot-P:tot);
		}
		if(!tot) return puo(X),0;
	}
	puo(-1);
	return 0;
}


#include<bits/stdc++.h>
#define it register int
#define ct const int
#define il inline
using namespace std;
typedef long long ll;
#define rll register ll
#define cll const ll
const int N=1000005;
#define P 1000003
int inv[20],x[N],y[N],o;
il void que(ct x){printf("? %d\n",x),fflush(stdout),scanf("%d",&o);}
il int ksm(it x,it L){it ans=1;while(L) L&1?ans=(0ll+ans)*x%P:0,x=(0ll+x)*x%P,L>>=1;return ans;}
il void puo(ct x){printf("! %d\n",x),fflush(stdout);}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	it i,j,ans,tot;
	for(i=0;i<=10;++i){
		x[i]=i,que(i),y[i]=o;
		if(!o) return puo(i),0;
	}
	for(i=0;i<=10;++i)
		for(j=0,inv[i]=1;j<=10;++j)
			if(i^j) inv[i]=(0ll+inv[i])*ksm(x[i]-x[j],P-2)%P;
	for(it X=11;X<P;++X){
		for(i=0,tot=0;i<=10;++i){
			for(j=0,ans=(0ll+y[i])*inv[i]%P;j<=10;++j)
				if(i^j) ans=(0ll+ans)*(X-x[j])%P;
			tot+=ans,tot=(tot>=P?tot-P:tot);
		}
		if(!tot) return puo(X),0;
	}
	puo(-1);
	return 0;
}


#include <cstdio>

const int z = 1e6+3;

int fp(int a, int x) {
    if (x == 0) return 1;
    if (x % 2 == 1) return 1ll * a * fp(a, x - 1) % z;
    int t = fp(a, x / 2);
    return 1ll * t * t % z;
}
int inv(int a) {
    return fp(a, z - 2);
}
int main() {
    int n = 11;
    int mat[n+1][n+2];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            mat[i][j] = fp(i-1, j);
    for (int i = 0; i <= 10; i++) {
        printf("? %d\n", i);
        fflush(stdout);
        scanf("%d", &mat[i][n+1]);
    }

    for(int i=1;i<=n;i++){
        int r=i;
        for(int j=i+1;j<=n;j++)
            if(mat[r][i]<mat[j][i])
                r=j;
        if(i!=r){
            for(int j=0;j<=n+1;j++) {
                int t=mat[i][j];
                mat[i][j]=mat[r][j];
                mat[r][j] = t;
            }
        }
        int div=inv(mat[i][i]);
        for(int j=i;j<=n+1;j++)
            mat[i][j]=1ll*mat[i][j]*div%z;
        for(int j=i+1;j<=n;j++){
            div=mat[j][i];
            for(int k=i;k<=n+1;k++)
                mat[j][k]=(mat[j][k]+z-1ll*mat[i][k]*div%z)%z;
        }
    }

    int a[n+1];
    a[n]=mat[n][n+1];
    for(int i=n-1;i>=1;i--){
        a[i]=mat[i][n+1];
        for(int j=i+1;j<=n;j++)
            a[i]=(a[i]+z-1ll*mat[i][j]*a[j]%z)%z;
    }

    for (int i = 0; i < z; i++) {
        int f = 0;
        for (int j = 0; j <= 10; j++) {
            f = (f + 1ll * a[j+1] * fp(i, j)) % z;
        }
        if (f == 0) {
            printf("! %d\n", i);
        }
    }

    return 0;
}


#include <cstdio>

const int z = 1e6+3;

int fp(int a, int x) {
    if (x == 0) return 1;
    if (x % 2 == 1) return 1ll * a * fp(a, x - 1) % z;
    int t = fp(a, x / 2);
    return 1ll * t * t % z;
}
int inv(int a) {
    return fp(a, z - 2);
}
int main() {
    int n = 11;
    int mat[n+1][n+2];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            mat[i][j] = fp(i-1, j-1);
    for (int i = 0; i <= 10; i++) {
        printf("? %d\n", i);
        fflush(stdout);
        scanf("%d", &mat[i+1][n+1]);
    }

    for(int i=1;i<=n;i++){
        int r=i;
        for(int j=i+1;j<=n;j++)
            if(mat[r][i]<mat[j][i])
                r=j;
        if(i!=r){
            for(int j=0;j<=n+1;j++) {
                int t=mat[i][j];
                mat[i][j]=mat[r][j];
                mat[r][j] = t;
            }
        }
        int div=inv(mat[i][i]);
        for(int j=i;j<=n+1;j++)
            mat[i][j]=1ll*mat[i][j]*div%z;
        for(int j=i+1;j<=n;j++){
            div=mat[j][i];
            for(int k=i;k<=n+1;k++)
                mat[j][k]=(mat[j][k]+z-1ll*mat[i][k]*div%z)%z;
        }
    }

    int a[n+1];
    a[n]=mat[n][n+1];
    for(int i=n-1;i>=1;i--){
        a[i]=mat[i][n+1];
        for(int j=i+1;j<=n;j++)
            a[i]=(a[i]+z-1ll*mat[i][j]*a[j]%z)%z;
    }

    for (int i = 0; i < z; i++) {
        int f = 0;
        for (int j = 0; j <= 10; j++) {
            f = (f + 1ll * a[j+1] * fp(i, j)) % z;
        }
        if (f == 0) {
            printf("! %d\n", i);
            fflush(stdout);
            return 0;
        }
    }

    printf("-1\n");
    fflush(stdout);

    return 0;
}


#include <cstdio>

const int z = 1e6+3;

int fp(int a, int x) {
    if (x == 0) return 1;
    if (x % 2 == 1) return 1ll * a * fp(a, x - 1) % z;
    int t = fp(a, x / 2);
    return 1ll * t * t % z;
}
int inv(int a) {
    return fp(a, z - 2);
}
int main() {
    int n = 11;
    int mat[n+1][n+2];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            mat[i][j] = fp(i-1, j-1);
    for (int i = 0; i <= 10; i++) {
        printf("? %d\n", i);
        fflush(stdout);
        scanf("%d", &mat[i][n+1]);
    }

    for(int i=1;i<=n;i++){
        int r=i;
        for(int j=i+1;j<=n;j++)
            if(mat[r][i]<mat[j][i])
                r=j;
        if(i!=r){
            for(int j=0;j<=n+1;j++) {
                int t=mat[i][j];
                mat[i][j]=mat[r][j];
                mat[r][j] = t;
            }
        }
        int div=inv(mat[i][i]);
        for(int j=i;j<=n+1;j++)
            mat[i][j]=1ll*mat[i][j]*div%z;
        for(int j=i+1;j<=n;j++){
            div=mat[j][i];
            for(int k=i;k<=n+1;k++)
                mat[j][k]=(mat[j][k]+z-1ll*mat[i][k]*div%z)%z;
        }
    }

    int a[n+1];
    a[n]=mat[n][n+1];
    for(int i=n-1;i>=1;i--){
        a[i]=mat[i][n+1];
        for(int j=i+1;j<=n;j++)
            a[i]=(a[i]+z-1ll*mat[i][j]*a[j]%z)%z;
    }

    for (int i = 0; i < z; i++) {
        int f = 0;
        for (int j = 0; j <= 10; j++) {
            f = (f + 1ll * a[j+1] * fp(i, j)) % z;
        }
        if (f == 0) {
            printf("! %d\n", i);
            fflush(output);
            return 0;
        }
    }

    printf("-1\n");
    fflush(output);

    return 0;
}


#include <cstdio>

const int z = 1e6+3;

int fp(int a, int x) {
    if (x == 0) return 1;
    if (x % 2 == 1) return 1ll * a * fp(a, x - 1) % z;
    int t = fp(a, x / 2);
    return 1ll * t * t % z;
}
int inv(int a) {
    return fp(a, z - 2);
}
int main() {
    int n = 11;
    int mat[n+1][n+2];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            mat[i][j] = fp(i-1, j-1);
    for (int i = 0; i <= 10; i++) {
        printf("? %d\n", i);
        fflush(stdout);
        scanf("%d", &mat[i+1][n+1]);
    }

    for(int i=1;i<=n;i++){
        int r=i;
        for(int j=i+1;j<=n;j++)
            if(mat[r][i]<mat[j][i])
                r=j;
        if(i!=r){
            for(int j=0;j<=n+1;j++) {
                int t=mat[i][j];
                mat[i][j]=mat[r][j];
                mat[r][j] = t;
            }
        }
        int div=inv(mat[i][i]);
        for(int j=i;j<=n+1;j++)
            mat[i][j]=1ll*mat[i][j]*div%z;
        for(int j=i+1;j<=n;j++){
            div=mat[j][i];
            for(int k=i;k<=n+1;k++)
                mat[j][k]=(mat[j][k]+z-1ll*mat[i][k]*div%z)%z;
        }
    }

    int a[n+1];
    a[n]=mat[n][n+1];
    for(int i=n-1;i>=1;i--){
        a[i]=mat[i][n+1];
        for(int j=i+1;j<=n;j++)
            a[i]=(a[i]+z-1ll*mat[i][j]*a[j]%z)%z;
    }

    for (int i = 0; i < z; i++) {
        int f = 0;
        for (int j = 0; j <= 10; j++) {
            f = (f + 1ll * a[j+1] * fp(i, j)) % z;
        }
        if (f == 0) {
            printf("! %d\n", i);
            fflush(output);
            return 0;
        }
    }

    printf("-1\n");
    fflush(output);

    return 0;
}


#include <cstdio>

const int Z = 1e6+3;
const int K = 11;

int fp(int a, int x) {
    if (x == 0) {
        return 1;
    }
    if (x % 2 == 1) {
        return 1ll * a * fp(a, x - 1) % Z;
    }
    int t = fp(a, x / 2);
    return 1ll * t * t % Z;
}

int inv(int a) {
    return fp(a, Z - 2);
}

int main() {
    int mat[K][K+1];
    for (int i = 0; i < K; i++) {
        for (int j = 0; j < K; j++) {
            mat[i][j] = fp(i, j);
        }

        printf("? %d\n", i);
        fflush(stdout);
        scanf("%d", &mat[i][K]);
    }

    for (int i = 0; i < K; i++) {
        int r = i;
        for (int j = i + 1; j < K; j++) {
            if (mat[j][i] > mat[r][i]) {
                r = j;
            }
        }
        for (int j = 0; j <= K; j++) {
            int t = mat[i][j];
            mat[i][j] = mat[r][j];
            mat[r][j] = t;
        }

        int d = inv(mat[i][i]);
        for (int j = i; j <= K; j++) {
            mat[i][j] = 1ll * mat[i][j] * d % Z;
        }

        for (int j = i + 1; j < K; j++) {
            for (int k = K; k >= i; k--) {
                mat[j][k] = (mat[j][k] - 1ll * mat[j][i] * mat[i][k] % Z + Z) % Z;
            }
        }
    }

    for (int i = K - 1; i >= 0; i--) {
        for (int j = i + 1; j < K; j++) {
            mat[i][K] = (mat[i][K] - 1ll * mat[i][j] * mat[j][K] % Z + Z) % Z;
            mat[i][j] = 0;
        }
    }

    for (int i = 0; i < Z; i++) {
        int f = 0, ip = 1;
        for (int j = 0; j < K; j++) {
            f = (f + 1ll * mat[j][K] * ip) % Z;
            ip = 1ll * ip * i % Z;
        }

        if (f == 0) {
            printf("! %d\n", i);
            fflush(stdout);
            return 0;
        }
    }

    printf("! -1\n");
    fflush(stdout);

    return 0;
}


#include <cstdio>

const int Z = 1e6+3;
const int K = 11;

int fp(int a, int x) {
    if (x == 0) {
        return 1;
    }
    if (x % 2 == 1) {
        return 1ll * a * fp(a, x - 1) % Z;
    }
    int t = fp(a, x / 2);
    return 1ll * t * t % Z;
}

int inv(int a) {
    return fp(a, Z - 2);
}

int main() {
    int mat[K][K+1];
    for (int i = 0; i < K; i++) {
        for (int j = 0; j < K; j++) {
            mat[i][j] = fp(i, j);
        }

        printf("? %d\n", i);
        fflush(stdout);
        scanf("%d", &mat[i][K]);
    }

    for (int i = 0; i < K; i++) {
        int r = i;
        for (int j = i + 1; j < K; j++) {
            if (mat[j][i] > mat[r][i]) {
                r = j;
            }
        }
        for (int j = 0; j <= K; j++) {
            int t = mat[i][j];
            mat[i][j] = mat[r][j];
            mat[r][j] = t;
        }

        int d = inv(mat[i][i]);
        for (int j = i; j <= K; j++) {
            mat[i][j] = 1ll * mat[i][j] * d % Z;
        }

        for (int j = i + 1; j < K; j++) {
            for (int k = i; k <= K; k++) {
                mat[j][k] = (mat[j][k] - 1ll * mat[j][i] * mat[i][k] % Z + Z) % Z;
            }
        }
    }

    for (int i = K - 2; i >= 0; i--) {
        for (int j = i + 1; j <= K; j++) {
            mat[i][K+1] = (mat[i][K+1] - 1ll * mat[i][j] * mat[j][K+1] % Z + Z) % Z;
            mat[i][j] = 0;
        }
    }

    int a[K];
    for (int i = 0; i < K; i++) {
        a[i] = mat[i][K+1];
    }

    for (int i = 0; i < Z; i++) {
        int f = 0, ip = 1;
        for (int j = 0; j < K; j++) {
            f = (f + 1ll * a[j] * ip) % Z;
            ip = 1ll * ip * i % Z;
        }

        if (f == 0) {
            printf("! %d\n", i);
            fflush(stdout);
            return 0;
        }
    }

    printf("! -1\n");
    fflush(stdout);

    return 0;
}


#include <cstdio>

const int Z = 1e6+3;
const int K = 11;

int fp(int a, int x) {
    if (x == 0) {
        return 1;
    }
    if (x % 2 == 1) {
        return 1ll * a * fp(a, x - 1) % Z;
    }
    int t = fp(a, x / 2);
    return 1ll * t * t % Z;
}

int inv(int a) {
    return fp(a, Z - 2);
}

int main() {
    int mat[K][K+1];
    for (int i = 0; i < K; i++) {
        for (int j = 0; j < K; j++) {
            mat[i][j] = fp(i, j);
        }

        printf("? %d\n", i);
        fflush(stdout);
        scanf("%d", &mat[i][K]);
    }

    for (int i = 0; i < K; i++) {
        int r = i;
        for (int j = i + 1; j < K; j++) {
            if (mat[j][i] > mat[r][i]) {
                r = j;
            }
        }
        for (int j = 0; j <= K; j++) {
            int t = mat[i][j];
            mat[i][j] = mat[r][j];
            mat[r][j] = t;
        }

        int d = inv(mat[i][i]);
        for (int j = i; j <= K; j++) {
            mat[i][j] = 1ll * mat[i][j] * d % Z;
        }

        for (int j = i + 1; j < K; j++) {
            for (int k = i; k <= K; k++) {
                mat[j][k] = (mat[j][k] - 1ll * mat[j][i] * mat[i][k] % Z + Z) % Z;
            }
        }
    }

    for (int i = K - 2; i >= 0; i--) {
        for (int j = i + 1; j <= K; j++) {
            mat[i][K] = (mat[i][K] - 1ll * mat[i][j] * mat[j][K] % Z + Z) % Z;
            mat[i][j] = 0;
        }
    }

    int a[K];
    for (int i = 0; i < K; i++) {
        a[i] = mat[i][K];
    }

    for (int i = 0; i < Z; i++) {
        int f = 0, ip = 1;
        for (int j = 0; j < K; j++) {
            f = (f + 1ll * a[j] * ip) % Z;
            ip = 1ll * ip * i % Z;
        }

        if (f == 0) {
            printf("! %d\n", i);
            fflush(stdout);
            return 0;
        }
    }

    printf("! -1\n");
    fflush(stdout);

    return 0;
}


#include <cstdio>

const int Z = 1e6+3;
const int K = 11;

int fp(int a, int x) {
    if (x == 0) {
        return 1;
    }
    if (x % 2 == 1) {
        return 1ll * a * fp(a, x - 1) % Z;
    }
    int t = fp(a, x / 2);
    return 1ll * t * t % Z;
}

int inv(int a) {
    return fp(a, Z - 2);
}

int main() {
    int mat[K][K+1];
    for (int i = 0; i < K; i++) {
        for (int j = 0; j < K; j++) {
            mat[i][j] = fp(i, j);
        }

        printf("? %d\n", i);
        fflush(stdout);
        scanf("%d", &mat[i][K]);
    }

    for (int i = 0; i < K; i++) {
        int r = i;
        for (int j = i + 1; j < K; j++) {
            if (mat[j][i] > mat[r][i]) {
                r = j;
            }
        }
        for (int j = 0; j <= K; j++) {
            int t = mat[i][j];
            mat[i][j] = mat[r][j];
            mat[r][j] = t;
        }

        int d = inv(mat[i][i]);
        for (int j = i; j <= K; j++) {
            mat[i][j] = 1ll * mat[i][j] * d % Z;
        }

        for (int j = i + 1; j < K; j++) {
            for (int k = i; k <= K; k++) {
                mat[j][k] = (mat[j][k] - 1ll * mat[j][i] * mat[i][k] % Z + Z) % Z;
            }
        }
    }

    for (int i = K - 2; i >= 0; i--) {
        for (int j = i + 1; j <= K; j++) {
            mat[i][K+1] = (mat[i][K+1] - 1ll * mat[i][j] * mat[j][K+1] % Z + Z) % Z;
            mat[i][j] = 0;
        }
    }

    int a[K];
    for (int i = 0; i < K; i++) {
        a[i] = mat[i][K+1];
    }

    for (int i = 0; i < Z; i++) {
        int f = 0, ip = 1;
        for (int j = 0; j < K; j++) {
            f = (f + 1ll * a[j] * ip) % Z;
            ip = 1ll * ip * i % z;
        }

        if (f == 0) {
            printf("! %d\n", i);
            fflush(stdout);
            return 0;
        }
    }

    printf("! -1\n");
    fflush(stdout);

    return 0;
}


#include <cstdio>

const int z = 1e6+3;

int fp(int a, int x) {
    if (x == 0) return 1;
    if (x % 2 == 1) return 1ll * a * fp(a, x - 1) % z;
    int t = fp(a, x / 2);
    return 1ll * t * t % z;
}
int inv(int a) {
    return fp(a, z - 2);
}
int main() {
    int n = 11;
    int mat[n+1][n+2];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            mat[i][j] = fp(i-1, j-1);
    for (int i = 0; i <= 10; i++) {
        printf("? %d\n", i);
        fflush(stdout);
        scanf("%d", &mat[i+1][n+1]);
    }

    for(int i=1;i<=n;i++){
        int r=i;
        for(int j=i+1;j<=n;j++)
            if(mat[r][i]<mat[j][i])
                r=j;
        if(i!=r){
            for(int j=0;j<=n+1;j++) {
                int t=mat[i][j];
                mat[i][j]=mat[r][j];
                mat[r][j] = t;
            }
        }
        int div=inv(mat[i][i]);
        for(int j=i;j<=n+1;j++)
            mat[i][j]=1ll*mat[i][j]*div%z;
        for(int j=i+1;j<=n;j++){
            div=mat[j][i];
            for(int k=i;k<=n+1;k++)
                mat[j][k]=(mat[j][k]+z-1ll*mat[i][k]*div%z)%z;
        }
    }

    int a[n+1];
    a[n]=mat[n][n+1];
    for(int i=n-1;i>=1;i--){
        a[i]=mat[i][n+1];
        for(int j=i+1;j<=n;j++)
            a[i]=(a[i]+z-1ll*mat[i][j]*a[j]%z)%z;
    }

    for (int i = 0; i < z; i++) {
        int f = 0;
        for (int j = 0; j <= 10; j++) {
            f = (f + 1ll * a[j+1] * fp(i, j)) % z;
        }
        if (f == 0) {
            printf("! %d\n", i);
            fflush(stdout);
            return 0;
        }
    }

    printf("! -1\n");
    fflush(stdout);

    return 0;
}


#include <cstdio>

const int Z = 1e6+3;
const int K = 11;

int fp(int a, int x) {
    if (x == 0) {
        return 1;
    }
    if (x % 2 == 1) {
        return 1ll * a * fp(a, x - 1) % Z;
    }
    int t = fp(a, x / 2);
    return 1ll * t * t % Z;
}

int inv(int a) {
    return fp(a, Z - 2);
}

int main() {
    int mat[K][K+1];
    for (int i = 0; i < K; i++) {
        for (int j = 0; j < K; j++) {
            mat[i][j] = fp(i, j);
        }

        printf("? %d\n", i);
        fflush(stdout);
        scanf("%d", &mat[i][K]);
    }

    for (int i = 0; i < K; i++) {
        int r = i;
        for (int j = i + 1; j < K; j++) {
            if (mat[j][i] > mat[r][i]) {
                r = j;
            }
        }
        for (int j = 0; j <= K; j++) {
            int t = mat[i][j];
            mat[i][j] = mat[r][j];
            mat[r][j] = t;
        }

        int d = inv(mat[i][i]);
        for (int j = i; j <= K; j++) {
            mat[i][j] = 1ll * mat[i][j] * d % Z;
        }

        for (int j = i + 1; j < K; j++) {
            for (int k = i; k <= K; k++) {
                mat[j][k] = (mat[j][k] - 1ll * mat[j][i] * mat[i][k] % Z + Z) % Z;
            }
        }
    }

    for (int i = K - 1; i >= 0; i--) {
        for (int j = i + 1; j < K; j++) {
            mat[i][K] = (mat[i][K] - 1ll * mat[i][j] * mat[j][K] % Z + Z) % Z;
            mat[i][j] = 0;
        }
    }

    int a[K];
    for (int i = 0; i < K; i++) {
        a[i] = mat[i][K];
    }

    for (int i = 0; i < Z; i++) {
        int f = 0, ip = 1;
        for (int j = 0; j < K; j++) {
            f = (f + 1ll * a[j] * ip) % Z;
            ip = 1ll * ip * i % Z;
        }

        if (f == 0) {
            printf("! %d\n", i);
            fflush(stdout);
            return 0;
        }
    }

    printf("! -1\n");
    fflush(stdout);

    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
#define int long long
using namespace std;

const double EPS = 0.00001;
const double INF = 1e9;
const int MOD = 1e6 + 3.;
const int N = 30;
int gauss(vector<vector<double>> a, vector<double> &ans, double p) {
    int lx = a[0].size() - 1;
    int ly = a.size();
    vector<int> where(lx, -1);

    for(int col = 0, row = 0;col != lx && row != ly;col++) {
        int sel = row;
        for(int i = row;i < ly;i++) {
            if(abs(a[sel][col]) < abs(a[i][col])) sel = i;
        }
        if(abs(a[sel][col]) < EPS) {
            continue;
        }
        for(int i = col;i <= lx;i++) {
            swap(a[row][i], a[sel][i]);
        }
        where[col] = row;

        for(int i = 0;i < ly;i++) {
            if(i != row) {
                double c = fmod(a[i][col] / a[row][col], p);
                for(int j = row;j <= lx;j++) {
                    a[i][j] = fmod(a[i][j] + p - fmod(a[row][j] * c, p), p);
                    a[i][j] = fmod(a[i][j], p);
                }
            }
        }
        row++;
    }

    for(int i = 0;i < ly;i++)
        for(int j = 0;j <= lx;j++)
            a[i][j] = fmod(round(a[i][j]), p);

    ans.assign(lx, 0);
    for(int i = 0;i < lx;i++) {
        if(where[i] == -1) continue;
        ans[i] = fmod(a[where[i]][lx] / a[where[i]][i], p);
    }

    for(int i = 0;i < ly;i++) {
        double sum = 0.;
        for(int j = 0;j < lx;j++) {
            sum = fmod(sum + fmod(ans[j] * a[i][j], p) + p, p);
        }
        if(abs(sum - a[i][lx] ) > EPS) return 0;
    }

    for(int i = 0;i < lx;i++) {
        if(where[i] == -1) return INF;
    }

    return 1;
}

int32_t main() {
    vector<vector<double>> v(N, vector<double>(12));
    vector<double> ans;
    cout << fixed;

    for(int i = 0;i < N;i++) {
        cout << "? " << i << endl;
        int x;
        cin >> x;
        int xst = 1;
        for(int j = 0;j < 11;j++) {
            v[i][j] = xst;
            xst = (xst * i) % MOD;
        }
        v[i][11] = x;
    }

    // for(int i = 0;i < N;i++) {
    //     for(int j = 0;j < 12;j++) {
    //         cout << v[i][j] << ' ';
    //     }
    //     cout << endl;
    // }

    int cans = gauss(v, ans, 1e6 + 3.);
    if(ans[0] == 2) return ans[1];

    for(int i = 0;i < MOD;i++) {
        int tv = 1;
        int sum = 0;

        for(int j = 0;j < 11;j++) {
            sum = (sum + (tv * (int)ans[j]) % MOD) % MOD;
            tv = (tv * i) % MOD;
        }
        if(sum == 0) {
            cout << "! " << i;
            return 0;
        }
    }

    cout << "! -1";
    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

const double EPS = 0.00001;
const double INF = 1e9;
const int MOD = 1e6 + 3.;
const int N = 11;
int gauss(vector<vector<double>> a, vector<double> &ans, double p) {
    int lx = a[0].size() - 1;
    int ly = a.size();
    vector<int> where(lx, -1);

    for(int col = 0, row = 0;col != lx && row != ly;col++) {
        int sel = row;
        for(int i = row;i < ly;i++) {
            if(abs(a[sel][col]) < abs(a[i][col])) sel = i;
        }
        if(abs(a[sel][col]) < EPS) {
            continue;
        }
        for(int i = col;i <= lx;i++) {
            swap(a[row][i], a[sel][i]);
        }
        where[col] = row;

        for(int i = 0;i < ly;i++) {
            if(i != row) {
                double c = fmod(a[i][col] / a[row][col], p);
                for(int j = row;j <= lx;j++) {
                    a[i][j] = fmod(a[i][j] + p - fmod(a[row][j] * c, p), p);
                    a[i][j] = fmod(a[i][j], p);
                }
            }
        }
        row++;
    }

    for(int i = 0;i < ly;i++)
        for(int j = 0;j <= lx;j++)
            a[i][j] = fmod(round(a[i][j]), p);

    ans.assign(lx, 0);
    for(int i = 0;i < lx;i++) {
        if(where[i] == -1) continue;
        ans[i] = fmod(a[where[i]][lx] / a[where[i]][i], p);
    }

    for(int i = 0;i < ly;i++) {
        double sum = 0.;
        for(int j = 0;j < lx;j++) {
            sum = fmod(sum + fmod(ans[j] * a[i][j], p) + p, p);
        }
        if(abs(sum - a[i][lx] ) > EPS) return 0;
    }

    for(int i = 0;i < lx;i++) {
        if(where[i] == -1) return INF;
    }

    return 1;
}

int main() {
    vector<vector<double>> v(N, vector<double>(12));
    vector<double> ans;
    cout << fixed;

    for(int i = 0;i < N;i++) {
        cout << "? " << i << endl;
        int x;
        cin >> x;
        int xst = 1;
        for(int j = 0;j < 11;j++) {
            v[i][j] = xst;
            xst = (xst * i) % MOD;
        }
        v[i][11] = x;
    }

    // for(int i = 0;i < N;i++) {
    //     for(int j = 0;j < 12;j++) {
    //         cout << v[i][j] << ' ';
    //     }
    //     cout << endl;
    // }

    int cans = gauss(v, ans, 1e6 + 3.);
    // for(int x : ans) cout << x << ' ';

    for(int i = 0;i < MOD;i++) {
        int tv = 1;
        int sum = 0;
        for(int j = 0;j < 11;j++) {
            sum = (sum + (tv * (int)ans[j]) % MOD) % MOD;
            tv = (tv * i) % MOD;
        }
        if(sum == 0) {
            cout << "! " << i;
            return 0;
        }
    }

    cout << "! -1";
    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
#define int long long
using namespace std;

const double EPS = 0.00001;
const double INF = 1e9;
const int MOD = 1e6 + 3.;
const int N = 50;
int gauss(vector<vector<double>> a, vector<double> &ans, double p) {
    int lx = a[0].size() - 1;
    int ly = a.size();
    vector<int> where(lx, -1);

    for(int col = 0, row = 0;col != lx && row != ly;col++) {
        int sel = row;
        for(int i = row;i < ly;i++) {
            if(abs(a[sel][col]) < abs(a[i][col])) sel = i;
        }
        if(abs(a[sel][col]) < EPS) {
            continue;
        }
        for(int i = col;i <= lx;i++) {
            swap(a[row][i], a[sel][i]);
        }
        where[col] = row;

        for(int i = 0;i < ly;i++) {
            if(i != row) {
                double c = fmod(a[i][col] / a[row][col], p);
                for(int j = row;j <= lx;j++) {
                    a[i][j] = fmod(a[i][j] + p - fmod(a[row][j] * c, p), p);
                    a[i][j] = fmod(a[i][j], p);
                }
            }
        }
        row++;
    }

    for(int i = 0;i < ly;i++)
        for(int j = 0;j <= lx;j++)
            a[i][j] = fmod(round(a[i][j]), p);

    ans.assign(lx, 0);
    for(int i = 0;i < lx;i++) {
        if(where[i] == -1) continue;
        ans[i] = fmod(a[where[i]][lx] / a[where[i]][i], p);
    }

    for(int i = 0;i < ly;i++) {
        double sum = 0.;
        for(int j = 0;j < lx;j++) {
            sum = fmod(sum + fmod(ans[j] * a[i][j], p) + p, p);
        }
        if(abs(sum - a[i][lx] ) > EPS) return 0;
    }

    for(int i = 0;i < lx;i++) {
        if(where[i] == -1) return INF;
    }

    return 1;
}

int32_t main() {
    vector<vector<double>> v(N, vector<double>(12));
    vector<double> ans;
    cout << fixed;

    for(int i = 0;i < N;i++) {
        cout << "? " << i << endl;
        int x;
        cin >> x;
        int xst = 1;
        for(int j = 0;j < 11;j++) {
            v[i][j] = xst;
            xst = (xst * i) % MOD;
        }
        v[i][11] = x;
    }

    // for(int i = 0;i < N;i++) {
    //     for(int j = 0;j < 12;j++) {
    //         cout << v[i][j] << ' ';
    //     }
    //     cout << endl;
    // }

    int cans = gauss(v, ans, 1e6 + 3.);

    for(int i = 0;i < MOD;i++) {
        int tv = 1;
        int sum = 0;

        for(int j = 0;j < 11;j++) {
            sum = (sum + (tv * (int)ans[j]) % MOD) % MOD;
            tv = (tv * i) % MOD;
        }
        if(sum == 0) {
            if(ans[0] == 2) return ans[1];
            cout << "! " << i;
            return 0;
        }
    }

    cout << "! -1";
    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
#define int long long
using namespace std;

const double EPS = 0.00001;
const double INF = 1e9;
const int MOD = 1e6 + 3.;
const int N = 30;
int gauss(vector<vector<double>> a, vector<double> &ans, double p) {
    int lx = a[0].size() - 1;
    int ly = a.size();
    vector<int> where(lx, -1);

    for(int col = 0, row = 0;col != lx && row != ly;col++) {
        int sel = row;
        for(int i = row;i < ly;i++) {
            if(abs(a[sel][col]) < abs(a[i][col])) sel = i;
        }
        if(abs(a[sel][col]) < EPS) {
            continue;
        }
        for(int i = col;i <= lx;i++) {
            swap(a[row][i], a[sel][i]);
        }
        where[col] = row;

        for(int i = 0;i < ly;i++) {
            if(i != row) {
                double c = fmod(a[i][col] / a[row][col], p);
                for(int j = row;j <= lx;j++) {
                    a[i][j] = fmod(a[i][j] + p - fmod(a[row][j] * c, p), p);
                    a[i][j] = fmod(a[i][j], p);
                }
            }
        }
        row++;
    }

    for(int i = 0;i < ly;i++)
        for(int j = 0;j <= lx;j++)
            a[i][j] = fmod(round(a[i][j]), p);

    ans.assign(lx, 0);
    for(int i = 0;i < lx;i++) {
        if(where[i] == -1) continue;
        ans[i] = fmod(a[where[i]][lx] / a[where[i]][i], p);
    }

    for(int i = 0;i < ly;i++) {
        double sum = 0.;
        for(int j = 0;j < lx;j++) {
            sum = fmod(sum + fmod(ans[j] * a[i][j], p) + p, p);
        }
        if(abs(sum - a[i][lx] ) > EPS) return 0;
    }

    for(int i = 0;i < lx;i++) {
        if(where[i] == -1) return INF;
    }

    return 1;
}

int32_t main() {
    vector<vector<double>> v(N, vector<double>(12));
    vector<double> ans;
    cout << fixed;

    for(int i = 0;i < N;i++) {
        cout << "? " << i << endl;
        int x;
        cin >> x;
        int xst = 1;
        for(int j = 0;j < 11;j++) {
            v[i][j] = xst;
            xst = (xst * i) % MOD;
        }
        v[i][11] = x;
    }

    // for(int i = 0;i < N;i++) {
    //     for(int j = 0;j < 12;j++) {
    //         cout << v[i][j] << ' ';
    //     }
    //     cout << endl;
    // }

    int cans = gauss(v, ans, 1e6 + 3.);

    for(int i = 0;i < MOD;i++) {
        int tv = 1;
        int sum = 0;
        for(int j = 0;j < 11;j++) {
            sum = (sum + (tv * (int)ans[j]) % MOD) % MOD;
            tv = (tv * i) % MOD;
        }
        if(sum == 0) {
            cout << "! " << i;
            return 0;
        }
    }

    cout << "! -1";
    return 0;
}