#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
#include <functional>

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL
#define rep(i,a,n) for (int i=a ; i<n ; i++)
#define per(i,a,n) for (int i=n-1 ; i>=a ; i--)
#define LLINF (llong)1e18+5
#define INF 1e9+1
#define endl '\n'

using namespace std;
using llong = long long;
using VI = vector<int>;
using VLL = vector<long long>;
using PII = pair<int, int>;

//struct cmp {
//	bool operator() (pair<PII, int> a, pair<PII, int> b)
//	{
//		return a.ss > b.ss;
//	}
//};

int main()
{
	IOS;

	int n;
	cin >> n;
	VI a(n);
	int ans = INF;
	rep(i, 0, n) {
		cin >> a[i];
		int mmax = max(n - 1 - i, i);
		ans = min(ans, a[i] / mmax);
	}
	cout << ans;
	return 0;
}


#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
   int n;
   int i,x=0;
   double y;
   int res=0x7fffffff;
   scanf("%d",&n);
   for(i=1;i<=n;i++){
        scanf("%d",&x);
        y=(1.0*x)/(max(i-1,n-i));
        x=(int)y;
        if(x<res)res=x;
   }
   printf("%d\n",res);

    return 0;
}


#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
   int n;
   int i,x;
   double y;
   int res=0x7fffffff;
   scanf("%d",&n);
   for(i=1;i<=n;i++){
        scanf("%d",&x);
        y=(1.0*x)/(max(i-1,n-i));
        x=(int)y;
        if(x<res)res=x;
   }
   printf("%d\n",res);

    return 0;
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;

void solve(int n, vector<int>& a) {
	int ans = INT_MAX;
	for (int i=0; i<n; i++) {
		for (int j=i+1; j<n; j++) {
			if (i != j) {
				int tmp = min(a[i], a[j])/(j - i);
				ans = min(ans, tmp);
			}
		}
	}
	cout << ans << endl;
}

int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i=0; i<n; i++)
		cin >> a[i];
	solve(n, a);
	return 0;
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;

void solve(int n, vector<int>& a) {
	int ans = INT_MAX;
	for (int i=0; i<n; i++) {
		ans = min(ans, a[i]/max(i, n - (i + 1))); // max(i' - 1, n - i'), i' = i + 1
	}
	cout << ans << endl;
}

int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i=0; i<n; i++)
		cin >> a[i];
	solve(n, a);
	return 0;
}


#include<iostream>
using namespace std;
const int N = 300000;
double min(int a, int b) {
	return (a < b ? a : b);
}
int main() {
	int n, i, *a;
	int l = 0;
	cin >> n;
	a=new int[n];
	for (int i = 0; i < n; i++) cin >> a[i];
	double x = min(a[0], a[n - 1]);
	double M = n - 1, y, m;
	if(x==0) i=n;
	for (i = 1; i < n; i++) {
		y = a[i];
		if(y==0){
		    x=0;
		    break;
		}
		double z = (y * M) / x;
		if ((int)z == z) m = (int)z;
		else m = (int)z + 1;
		if (n - 1 - i >= m) {
			x = min(a[i], a[i - 1]);
			M = n - 1 - i;
		}
		if (i >= m) {
			if (x / M > min(a[i], a[0]) / i) {
				x = min(a[i], a[0]);
				M = i;
			}
		}
	}
	double k = x / M;
	cout << (int)k;
}


#include<iostream>
using namespace std;
const int N = 300000;
double min(int a, int b) {
	return (a < b ? a : b);
}
int main() {
	int n, i, *a;
	int l = 0;
	cin >> n;
	a=new int[n];
	for (int i = 0; i < n; i++) cin >> a[i];
	double x = min(a[0], a[n - 1]);
	double M = n - 1, y, m;
	for (int i = 1; i < n; i++) {
		y = a[i];
		double z = (y * M) / x;
		if ((int)z == z) m = (int)z;
		else m = (int)z + 1;
		if (n - 1 - i >= m) {
			x = min(a[i], a[i - 1]);
			M = n - 1 - i;
		}
		if (i >= m) {
			if (x / M > min(a[i], a[0]) / i) {
				x = min(a[i], a[0]);
				M = i;
			}
		}
	}
	double k = x / M;
	cout << (int)k;
}


#include<cstdio>
#include<string>
#include<string.h>
#include<map>
#include<queue>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<stack>
#define inf 0x3f3f3f3f
#define P(x,y)  make_pair(x,y)
#define lowbit(i1) (i1)&(-i1)
using namespace std;

long long a[3000100];

int main()
{
	int n;
	scanf_s("%d", &n);
	int ans = inf;
	for (int i = 1; i <= n; i++)
	{
		int x;
		scanf_s("%d", &x);
		ans = min(ans, x / max(n - i, i - 1));
	}
	printf("%d", ans);
	return 0;
}


#include <iostream>
#include <vector>
#include<iomanip>
#include <cstring>
#include <string.h>
#include <iterator>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <limits.h>
#include <string>
#include <bitset>
#include <map>
#include <numeric>

#define endl cout<<"\n"
#define lli long long int
#define ld long double
#define M_PI (3.14159265358979323846264338327950288)
#define MOD (1000000007)

using namespace std;

//fast-exponentiation-lli
lli expo_fast(lli a, lli b) {
	a = a;
	lli result = 1;
	while (b) {
		//multiplyint(tos(result), a);
		if (b & 1)result = (result * a);
		b >>= 1;
		a = (a*a);
	}
	return (result);
}

void take_in(vector<lli> *arr) {
	for (int i = 0; i < arr->size(); i++)cin >> (*(arr))[i];
}

void disp_arr(vector<lli>* arr) {
	for (int i = 0; i < arr->size(); i++)cout << (*(arr))[i] << " ";
}

lli gcd(lli a, lli b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);

}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n; cin >> n;
	vector<lli> arr(n); take_in(&arr);
	lli min_ = LLONG_MAX;
	for (int i = 0; i < n - 1; i++) {
		if (i == 0) {
			min_ = min(min_,  (min(arr[i], arr[n - 1]) / (n - 1 - i)));
		}
		else if (i == n - 1) {
			min_ = min(min_, min(min(arr[i], arr[0]) / i,LLONG_MAX));
		}
		else min_ = min(min_, min(min(arr[i], arr[0]) / i, min(arr[i], arr[n - 1]) / (n - 1 - i)));
	}
	cout << min_;
//	system("PAUSE");
}


#include<iostream>
#include<algorithm>
using namespace std;
int n;
int temp;
int ans = 1e9;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> temp;
        ans = min(ans,temp/max(i,n-i-1));
    }
    cout << ans << endl;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int i, j, n;
int a[300003];
int k = 0x3f3f3f3f;
int main()
{

    cin >> n;
    for(i=0;i<n;i++)
        cin >> a[i];
    for(i = 0;i < n - 1;i++){
        if(a[i]==0){
            cout << 0 << endl;
            return 0;
        }
        for(j = i + 1;j < n;j++){
            if(a[j]==0){
                cout << 0 << endl;
                return 0;
            }
            k = min(k,min(a[i],a[j])/abs(i-j));
        }
    }
    cout << k << endl;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int i, j, n;
int a[300003];
int k = 0x3f3f3f3f;
int main()
{

    cin >> n;
    for(i=0;i<n;i++)
        cin >> a[i];
    for(i = 0;i < n - 1;i++){
        for(j = i + 1;j < n;j++){
            if(a[j]==0){
                cout << 0 << endl;
                return 0;
            }
            k = min(k,min(a[i],a[j])/abs(i-j));
        }
    }
    cout << k << endl;
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int n;
int temp;
int ans = 1e9;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> temp;
        ans = min(ans,temp/max(i,n-i-1));
    }
    cout << ans << endl;
    return 0;
}


#include<iostream>
using namespace std;
int n;
int temp;
int ans = 1e9;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> temp;
        ans = min(ans,temp/max(i,n-i-1));
    }
    cout << ans << endl;
    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
int main()
{
	long long int ans=INT_MAX,k=0,c,n,i,j,a,b;
	cin>>n;
	vector <long long int > v(n);
	for(i=0;i<n;i++)
		cin>>v[i];
	for(i=0;i<n;i++)
	{
		k=v[i]/(max(i,n-i-1));
		if(k<ans)
			ans=k;
	}

	cout<<ans<<endl;
}


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

int main()
{
	long long int ans=INT_MAX,k=0,c,n,i,j,a,b;
	cin>>n;
	vector <long long int > v(n);
	for(i=0;i<n;i++)
		cin>>v[i];
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			a=min(v[i],v[j]);
			b=abs(i-j);
			k=a/b;
			while(k*b>a)
			{
				k--;
			}
			ans=min(k,ans);
		}
	}
	cout<<ans<<endl;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <assert.h>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cstdio>

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define int long long

using namespace std;

const int INF = 2e9;
const int MOD = 998244353;

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int ans = INF;
	for (int i = 0; i < n; i++) {
		if(i != 0) ans = min(ans, min(a[i], a[0]) / i);
		if(i != n - 1) ans = min(ans, min(a[i], a[n - 1]) / (n - 1 - i));
	}
	cout << ans;
}
signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(12);
	solve();
}


#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <iostream>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <list>
#include <random>
#include <functional>
#include <cmath>

using namespace std;

void solve() {
	int n;
	cin >> n;
	auto A = vector<int>(n);
	for (auto& a : A)
		cin >> a;

	int ans = 1e9 + 1;
	for (auto i = 0; i < n; ++i) {
		if(i > 0)
			ans = min(ans, min(A[i], A[0]) / i);
		if (i < n - 1)
			ans = min(ans, min(A[i], A[n-1]) /(n - i - 1));
	}

	cout << ans << endl;
}

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	solve();
	return 0;
}


#include <iostream>

using namespace std;

int n =0;
int a = 1e9 + 10;

int min(int a, int b) {
	if (a<b)
	{
		return a;
	}
	else {
		return b;
	}
}

int max(int a, int b) {
	if (a < b) {
		return b;
	}
	else {
		return a;
	}

}

int main() {
	while (cin >> n)
	{
		int ans = 1e9 + 10;
		for (int i = 0; i < n; i++)
		{
			cin >> a;
		    ans = min(ans, a / max(n - i, i - 1));
		}

		cout << ans << endl;

	}
	return 0;
}


#include <iostream>

using namespace std;

int n =0;
int a = 1e9 + 10;

int min(int a, int b) {
	if (a<b)
	{
		return a;
	}
	else {
		return b;
	}
}

int max(int a, int b) {
	if (a < b) {
		return b;
	}
	else {
		return a;
	}

}

int main() {
	while (cin >> n)
	{
		int ans = 1e9 + 10;
		for (int i = 0; i < n; i++)
		{
			cin >> a;
		    ans = min(ans, a / max(n - i -1, i));
		}

		cout << ans << endl;

	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<vector>
#include<set>
#define ll long long
#define mes(x,y) memset(x,y,sizeof(x))
using namespace std;
int main(){
	int n;
	while(cin>>n){
		ll flag=0,x,v;ll minn=1000000029;
		for(int i=1;i<=n;i++){
			cin>>x;
			v=max(i-1,n-i);
			x/=v;
			minn=min(minn,x);
		}
		//cout<<minn<<" "<<flag<<endl;
		cout<<minn<<endl;
	}
}


#include <algorithm>
#include <functional>
#include <cmath>
#include <limits>
#include <cfloat>
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef int64_t I64;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define fr(i,a,b) for (int i = a; i <= b; i++)

const int N = 300007;
int a[N];

int main() {
	ios_base::sync_with_stdio(false);

	int n;
	cin >> n;

	fr(i, 0, n - 1) cin >> a[i];

	int k = -1;
	fr(i, 0, n - 1) {
		if (i > 0) {
			int k1 = min(a[0], a[i]) / i;
			if ((k < 0) || (k1 < k)) k = k1;
		}

		if (i < n - 1) {
			int k2 = min(a[n - 1], a[i]) / (n - 1 - i);
			if ((k < 0) || (k2 < k)) k = k2;
		}
	}

	cout << ((k >= 0) ? k : 0);

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <time.h>
//#include <math.h>
#include <cmath>
#include <fstream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <iomanip>
#include <cstdio>
#include <cassert>

using namespace std;

#define flu fflush(stdout)
#define gg return 0
#define mp make_pair

long long mod = /*27449*//*998244353*/ 1e9 + 7;
long long inf = 1e18;
double eps = 1e-8;
double pi = acos(-1);
ifstream in("input.txt");
ofstream out("output.txt");

int main()
{
	int n;
	cin >> n;
	vector<long long> a;
	for (int i = 0; i < n; i++)
	{
		long long t;
		cin >> t;
		a.push_back(t);
	}
	long long l = 0, r = 1e9;
	while (r - l > 1)
	{
		long long m = (l + r) / 2;
		int f = 1;
		for (long long i = 0; i < n; i++)
		{
			if (m * max(i, n - i - 1) > a[i])
			{
				f = 0;
				break;
			}
		}
		if (f)
		{
			l = m;
		}
		else
		{
			r = m;
		}
	}
	cout << l;
	gg;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <time.h>
//#include <math.h>
#include <cmath>
#include <fstream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <iomanip>
#include <cstdio>
#include <cassert>

using namespace std;

#define flu fflush(stdout)
#define gg return 0
#define mp make_pair

long long mod = /*27449*//*998244353*/ 1e9 + 7;
long long inf = 1e18;
double eps = 1e-8;
double pi = acos(-1);
ifstream in("input.txt");
ofstream out("output.txt");

int main()
{
	int n;
	cin >> n;
	vector<long long> a;
	for (int i = 0; i < n; i++)
	{
		long long t;
		cin >> t;
		a.push_back(t);
	}
	long long l = 0, r = 1e9 + 5;
	while (r - l > 1)
	{
		long long m = (l + r) / 2;
		int f = 1;
		for (long long i = 0; i < n; i++)
		{
			if (m * max(i, n - i - 1) > a[i])
			{
				f = 0;
				break;
			}
		}
		if (f)
		{
			l = m;
		}
		else
		{
			r = m;
		}
	}
	cout << l;
	gg;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin>>n;

    int final_k=1000000000;
    vector<int> a(n);

    int k;
    for(int i=0;i<n;i++)
    {
        cin>>k;
        a[i]=k;
    }

    int x;
    for(int i=0;i<n;i++)
    {
        if(i>=n/2)
        {
            x=i-n/2;
        }
        k=a[i]/(n-x);

        if(k<final_k)
            final_k=k;
    }

    cout<<final_k;

   return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin>>n;

    int final_k=1000000000;
    vector<int> a(n);

    int k;
    for(int i=0;i<n;i++)
    {
        cin>>k;
        a[i]=k;
    }

    int max;
    for(int i=0;i<n;i++)
    {
        max=n-i-1>i?n-i-1:i;
        k=a[i]/max;

        if(k<final_k)
            final_k=k;
    }

    cout<<final_k;

   return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin>>n;

    int final_k=10000000000;
    vector<int> a(n);

    int k;
    for(int i=0;i<n;i++)
    {
        cin>>k;
        a[i]=k;
    }

    int x;
    for(int i=0;i<n;i++)
    {
        if(i>=n/2)
        {
            x=i-n/2;
        }
        k=a[i]/(n-x);

        if(k<final_k)
            final_k=k;
    }

    cout<<k;

   return 0;
}


#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=3e5+50;
int n,a[N],c[N],m,p[2][N],ans=2e9;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)c[i]=a[i];
	sort(c+1,c+n+1);m=unique(c+1,c+n+1)-c-1;
	for(int i=1;i<=n;i++)a[i]=lower_bound(c+1,c+m+1,a[i])-c;

	for(int i=1;i<=n;i++){
		if(!p[0][a[i]])p[0][a[i]]=i;
		p[1][a[i]]=i;
	}
	for(int i=1;i<=m;i++){
		if(p[1][i]!=1)ans=min(ans,c[i]/(p[1][i]-1));
		if(p[0][i]!=n)ans=min(ans,c[i]/(n-p[0][i]));
	}
	printf("%d",ans);
	return 0;
}


#include<iostream>
using namespace std;

int min(int x, int y)
{
	if (x < y) { return x; }
	return y;
}

int max(int x, int y)
{
	if (x > y) { return x; }
	return y;
}
int main()
{
	int n; cin >> n;
	int *a = new int[n];

	int ans;

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i] = a[i] / max(i, n - 1 - i);

		if (i == 0) { ans = a[i]; }
		else
		{
			ans = min(ans, a[i]);
		}
	}
	cout << ans << endl;
	system("pause");
	return 0;
}


#include<iostream>
using namespace std;

int min(int x, int y)
{
	if (x < y) { return x; }
	return y;
}

int main()
{
	int n; cin >> n;
	int *a = new int[n];

	int minimum = 0;
	int minimumindex = 0;

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (i == 0) { minimum = a[i]; }

		else
		{
			if (a[i] < minimum)
			{
				minimum = a[i];
				minimumindex = i;
			}
		}
	}

	int x = minimum / (n - 1 - minimumindex);
	int y = minimum / minimumindex;
	int z = min(a[0], a[n - 1]) / (n - 1);
	cout << min(x, min(y, z));

	return 0;
}


#include<iostream>
using namespace std;

int min(int x, int y)
{
	if (x < y) { return x; }
	return y;
}

int max(int x, int y)
{
	if (x > y) { return x; }
	return y;
}
int main()
{
	int n; cin >> n;
	int *a = new int[n];

	int ans;

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i] = a[i] / max(i, n - 1 - i);

		if (i == 0) { ans = a[i]; }
		else
		{
			ans = min(ans, a[i]);
		}
	}
	cout << ans << endl;
	return 0;
}


#include<iostream>
using namespace std;

int min(int x, int y)
{
	if (x < y) { return x; }
	return y;
}

int main()
{
	int n; cin >> n;
	int *a = new int[n];

	int minimum = 0;
	int minimumindex = 0;

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (i == 0) { minimum = a[i]; }

		else
		{
			if (a[i] < minimum)
			{
				minimum = a[i];
				minimumindex = i;
			}
		}
	}

	int ans;
	if (minimumindex != 0)
	{
		ans = minimum / minimumindex;
	}
	else
	{
		ans = minimum;
	}

	for (int i = 0; i < n; i++)
	{
		if (i == minimumindex){}
		else
		{
			ans = min(ans, minimum / abs(minimumindex - i));
		}
	}

	cout << min(ans, min(a[0], a[n - 1]) / (n - 1));

	return 0;
}


#include<iostream>
using namespace std;

int min(int x, int y)
{
	if (x < y) { return x; }
	return y;
}

int main()
{
	int n; cin >> n;
	int *a = new int[n];

	int minimum = 0;
	int minimumindex = 0;

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (i == 0) { minimum = a[i]; }

		else
		{
			if (a[i] < minimum)
			{
				minimum = a[i];
				minimumindex = i;
			}
		}
	}

	int x = minimum / (n - minimumindex);
	int y = minimum / (minimumindex + 1);
	int z = min(a[0], a[n - 1]) / n;
	cout << min(x, min(y, z));

	return 0;
}


#include<iostream>
#include<set>
using namespace std;

int min(int x, int y)
{
	if (x < y) { return x; }
	return y;
}

int main()
{
	int n; cin >> n;
	int *a = new int[n];

	for (int i = 0; i < n; i++) { cin >> a[i]; }

	set<int> s;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			int b = min(a[i], a[j]) / (j - i);
			s.insert(b);
		}
	}

	set<int>::iterator it = s.begin();
	int minimum = *it;

	for (; it != s.end(); it++)
	{
		minimum = min(minimum, *it);
	}
	cout << minimum << endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<queue>
#include<string>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define N 300005
struct cnm
{
	long long zuobiao,zhi;
}w[N];
bool cmp(cnm a,cnm b)
{
	return a.zhi<b.zhi;
}
int main()
{
	int n;
	while(cin>>n)
	{
		ll minn=30000000;
		memset(w,0,sizeof(w));
		int i;
		for(i=0;i<n;i++)
		{
			cin>>w[i].zhi;
			w[i].zuobiao=i+1;
		}
		for(i=0;i<n;i++)
		{
			minn=min(w[i].zhi/max(w[i].zuobiao-1,n-w[i].zuobiao),minn);
		}
		cout<<minn<<endl;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<queue>
#include<string>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define N 300005
struct cnm
{
	long long zuobiao,zhi;
}w[N];
bool cmp(cnm a,cnm b)
{
	return a.zhi<b.zhi;
}
int main()
{
	int n;
	while(cin>>n)
	{
		ll minn=300000000000000000;
		memset(w,0,sizeof(w));
		int i;
		for(i=0;i<n;i++)
		{
			cin>>w[i].zhi;
			w[i].zuobiao=i+1;
		}
		for(i=0;i<n;i++)
		{
			minn=min(w[i].zhi/max(w[i].zuobiao-1,n-w[i].zuobiao),minn);
		}
		cout<<minn<<endl;
	}
	return 0;
}


#include<map>
#include<stdio.h>
#include<string>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<stdio.h>
#include<string>
#include<list>
#include<math.h>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<queue>
#include<limits>
using namespace std;
typedef long long  ll;
#define mod 1000000007

using namespace std;

int main()
{
	long long n, val, i = 1;
	long long min = INT_MAX;

	cin >> n;
	while (n--)
	{
		cin >> val;
		long long deno = max(i-1, n - i);
		if (val / deno < min)
			min = val / deno;
		i++;
	}

	cout << min << endl;
	return 0;
}


import sys

def solution(n, arr):
    if n % 2 == 0 and n != 2:
        print('NO')
    else:
        for x in arr:
            if x % 2 == 1:
                print('YES')
                return
        print('NO')

for line in sys.stdin:
    t = int(line)
    break

p = 1
for line in sys.stdin:
    temp = [int(x) for x in line.split()]
    if len(temp) == 1:
        n = temp[0]
    else:
        arr = temp
        solution(n, arr)


def add(n):
   sum=0
   o=0
   e=0
   a = list(map(int, input().split(' ')))
   for i in range(n):
       sum+=a[i]
       if(a[i]%2==0):
           e+=1
       else:
            o+=1
   if(sum%2==0):
        if(o==0 or (o%2==0 and e==0)):
            print("NO")
   else:
        print("YES")

t=int(input())
for i in range(t):
    n=int(input())
    add(n)


def add(n):
   sum=0
   o=0
   e=0
   a = list(map(int, input().split(' ')))
   for i in range(n):
       sum+=a[i]
       if(a[i]%2==0):
           e+=1
       else:
            o+=1
   if(sum%2==0):
        if(o==0 or (o%2==0 and e==0)):
            print("NO")
        else:
            print("YES")
   else:
        print("YES")

t=int(input())
for i in range(t):
    n=int(input())
    add(n)


def add(n):
    o=0
    e=0
    sum=0
    a=[]
    a = list(map(int, input().split(' ')))
    for i in range(n):
        sum+=a[i]
        if(a[i]%2==0):
            e=e+1
        else:
            o=o+1
    if(sum%2==0):
        if(o==0 or (o%2==0 and e==0)):
            print("NO")
        else:
            print("YES")
    else:
        print("YES")

t=int(input())
for i in range(t):
    n=int(input())
    add(n)


def add(n):
    sum=0
    a=[]
    a = list(map(int, input().split()))
    for i in range(n):
        sum+=a[i]
    if(sum%2==0):
        print("NO")
    else:
        print("YES")

t=int(input())
for i in range(t):
    n=int(input())
    add(n)


n = int(input())
for i in range(n):
    q = int(input())
    l = list(map(int, input().split()))
    a, b = 0, 0
    for j in range(q):
        if l[j] % 2 == 0:
            a += 1
        else:
            b += 1
    if (a == 0 or b == 0) and q % 2 == 0:
        print("NO")
    else:
        print("YES")


n = int(input())
for i in range(n):
    q = int(input())
    l = list(map(int, input().split()))
    a, b = 0, 0
    for j in range(q):
        if l[j] % 2 == 0:
            a += 1
        else:
            b += 1
    if ((a == 0  and q % 2 == 0) or (b == 0) or (q == 1 and l[0] % 2 == 0)):
        print("NO")
    else:
        print("YES")


n = int(input())
for i in range(n):
    q = int(input())
    l = list(map(int, input().split()))

    a, b = 0, 0
    for j in range(q):
        if l[j] % 2 == 0:
            a += 1
        else:
            b += 1
    if ((a == 0 or b == 0) and q % 2 == 0) or (q == 1 and l[0] % 2 == 0):
        print("NO")
    else:
        print("YES")


t = int(input())

for i in range(t):
    n = int(input())
    a = list(map(int, input().split(" ")))
    sm = sum(a)
    flg = False
    if(sm % 2):
        print("YES")
    else:
        if a[0] % 2:
            for i in range(n):
                if a[i]%2:
                    print("YES")
                    flg=True
                    break
            if not flg:
                print("NO")
        else:
            for i in range(n):
                if not a[i] % 2:
                    print("YES")
                    flg=True
                    break
            if not flg:
                print("NO")


t = int(input())

for i in range(t):
    n = int(input())
    a = list(map(int, input().split(" ")))
    sm = sum(a)
    flg = True
    if(sm % 2):
        print("YES")
    else:
        if a[0] % 2:
            for i in range(n):
                if a[i]%2:
                    print("YES")
                    flg=True
                    break
            if not flg:
                print("NO")
        else:
            for i in range(n):
                if not a[i] % 2:
                    print("YES")
                    flg=True
                    break
            if not flg:
                print("NO")


t = int(input())

for i in range(t):
    a = list(map(int, input().split(" ")))
    sm = sum(a)
    if(sm%2):
        print("YES")
    else:
        print("NO")


t = int(input())

for i in range(t):
    n = int(input())
    a = list(map(int, input().split(" ")))
    sm = sum(a)
    if(sm % 2):
        print("YES")
    else:
        print("NO")


t = int(input())

for i in range(t):
    n = int(input())
    a = list(map(int, input().split(" ")))
    sm = sum(a)
    flg = False
    if(sm % 2):
        print("YES")
    else:
        if a[0] % 2:
            for i in range(n):
                if not a[i]%2:
                    print("YES")
                    flg=True
                    break
            if not flg:
                print("NO")
        else:
            for i in range(n):
                if a[i] % 2:
                    print("YES")
                    flg=True
                    break
            if not flg:
                print("NO")


t = int(input())

for i in range(t):
    n = int(input())
    a = list(map(int, input().split(" ")))
    sm = sum(a)
    if(sm % 2):
        print("YES")
    flg = False
    else:
        if a[0] % 2:
            for i in range(n):
                if a[i]%2:
                    print("YES")
                    flg=True
                    break
            if not flg:
                print("NO")
        else:
            for i in range(n):
                if not a[i] % 2:
                    print("YES")
                    flg=True
                    break
            if not flg:
                print("NO")


for tin in range(int(input())):
    n=int(input())
    a=list(map(int, input().split()))
    if sum(a)%2==0:
        print("NO")
    else:
        print("YES")


for tin in range(int(input())):
    n=int(input())
    a=list(map(int, input().split()))
    o=0
    e=0
    for _ in range(n):
        if a[_]%2==0:
            e+=1
        else:
            o+=1
    if o%2==1:
        print("YES")
    elif o%2==0 and e>=1 and o>=1:
        print("YES")
    else:
        print("NO")


for tin in range(int(input())):
    n=int(input())
    a=list(map(int, input().split()))
    o=0
    e=0
    for _ in range(n):
        if a[_]%2==0:
            e+=1
        else:
            o+=1
    if o%2==1:
        print("YES")
    elif o%2==0 and e>=1:
        print("YES")
    else:
        print("NO")


for tin in range(int(input())):
    n=int(input())
    a=list(map(int, input().split()))
    o=0
    e=0
    for _ in range(n):
        if a[_]%2==0:
            e+=1
        else:
            o+=1
    if o%2==1:
        print("YES")
    else:
        print("NO")


import sys
t = int(input())
while t:
    n = int(input())
    arr = list(map(int,sys.stdin.readline().split()))
    if sum(arr)%2==0:
        print("NO")
    else:
        print("YES")
    t-=1


import sys
t = int(input())
while t:
    n = int(input())
    arr = list(map(int,sys.stdin.readline().split()))
    oddcount = 0
    evencount = 0
    for i in range(n):
        if arr[i]%2==0:
            evencount+=1
        else:
            oddcount+=1

    if oddcount%2==1:
        print("YES")
    elif oddcount%2==0 and evencount>=1 and oddcount>=1:
        print("YES")
    else:
        print("NO")
    t-=1


import sys
t = int(input())
while t:
    n = int(input())
    arr = list(map(int,sys.stdin.readline().split()))
    oddcount = 0
    evencount = 0
    for i in range(n):
        if arr[i]%2==0:
            evencount+=1
        else:
            oddcount+=1
    if oddcount==0:
        print("NO")
    elif oddcount%2==evencount%2==0:
        print("NO")
    elif oddcount%2==evencount%2==1:
        print("YES")
    elif oddcount%2==1 and evencount%2==0:
        print("YES")
    elif oddcount%2==0 and evencount%2==1:
        print("YES")
    t-=1


t=int(input())
for _ in range(t):
    sum=0
    odd=0
    even=0
    n=int(input())
    a=list(map(int,input().split()))
    for i in a:
        sum=sum+i
        if i%2==1: odd+=1
        else: even+=1
    if sum%2==0:
     if odd>=1 and even>=1:
         print('YES')
     else:
         print('NO')
    else:
     print('YES')


t=int(input())
for _ in range(t):
    sum=0
    odd=0
    n=int(input())
    a=list(map(int,input().split()))
    for i in a:
        sum=sum+i
        if i%2==1: odd+=1
    if sum%2==0:
     if odd>=1:
         print('YES')
     else:
         print('NO')
    else:
     print('YES')


t=int(input())
for _ in range(t):
    sum=0
    n=int(input())
    a=list(map(int,input().split()))
    for i in a:
        sum=sum+i
    if sum%2==0:
     print('NO')
    else:
     print('YES')


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def oddsum():
    for _ in range(t):
        n = int(input())
        a = [int(x) for x in input().split()]
        if sum(a)%2==1:
            yield "YES"
        else:
            yield "NO"
if __name__ == '__main__':
    t= int(input())
    ans = oddsum()
    print(*ans,sep='\n')


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def oddsum():
    for _ in range(t):
        n = int(input())
        *a, = [int(x) for x in input().split()]
        if sum(a)%2==1:
            yield "YES"
        else:
            yield "NO"
if __name__ == '__main__':
    t= int(input())
    ans = oddsum()
    print(*ans,sep='\n')


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def oddsum():
    for _ in range(t):
        n = int(input())
        a = [int(x) for x in input().split()]
        if n%2==1:
            yield "YES"
            continue
        counto,counte=False,False
        for i in range(n):
            if a[i]%2==0 and not counte:
                counte=True
            elif a[i]%2==1 and not counto:
                counto=True
            if counto and counte:
                break
        if counto and counte:
            yield "YES"
        else:
            yield "NO"
if __name__ == '__main__':
    t= int(input())
    ans = oddsum()
    print(*ans,sep='\n')


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def oddsum():
    for _ in range(t):
        n = int(input())
        a = [int(x) for x in input().split()]

        counto,counte=False,False
        for i in range(n):
            if a[i]%2==0 and not counte:
                counte=True
            elif a[i]%2==1 and not counto:
                counto=True
            if counto and counte:
                break
        if counto and counte:
            yield "YES"
        else:
            if counto and n%2==1:
                yield "YES"
            else:
                yield "NO"
if __name__ == '__main__':
    t= int(input())
    ans = oddsum()
    print(*ans,sep='\n')


def solve():
    T=int(input())
    for t in range(T):
        n=int(input())
        ip=input().split()
        a=[int(x) for x in ip]

        e,o=0,0
        for i in range(n):
            if a[i]%2==0:
                e+=1
            else:
                o+=1

        if o%2 !=0:
            print("YES")
            continue

        elif o==0:
            print("NO")
            continue

        elif e==0 and o>0 and o%2==0:
            print("NO")
            continue

        elif e%2==0 and o%2==0:
            print("YES")
            continue

        else:
            print("NO")
            continue

solve()


def solve():
    T=int(input())
    for t in range(T):
        n=int(input())
        ip=input().split()
        a=[int(x) for x in ip]

        e,o=0,0
        for i in range(n):
            if a[i]%2==0:
                e+=1
            else:
                o+=1

        if o%2 !=0:
            print("YES")
            continue

        elif o==0:
            print("NO")
            continue

        elif e==0 and o>0 and o%2==0:
            print("NO")
            continue

        elif e>0 and o>0 and  o%2==0:
            print("YES")
            continue

        else:
            print("NO")
            continue

solve()


def solve():
    T=int(input())
    for t in range(T):
        n=int(input())
        ip=input().split()
        a=[int(x) for x in ip]

        e,o=0,0
        for i in range(n):
            if a[i]%2==0:
                e+=1
            else:
                o+=1

        if o%2 !=0:
            print("YES")
            continue

        elif o==0:
            print("NO")
            continue

        elif e==0 and o>0 and o%2==0:
            print("NO")
            continue

        elif e>0 and o>0 and e%2==0 and o%2==0:
            print("YES")
            continue

        else:
            print("NO")
            continue

solve()


def solve(n,ar):
    ans = []
    ans.append(sum(ar))

    if sum(ar)%2 != 0:
        print('YES')
        return

    else:
        for i in range(len(ans)): ##even
            if ans[i]%2 != 0: #if ar[i] is odd
                print('YES')
                return
        print('NO')

if __name__ == '__main__':
    t = int(input())

    for _ in range(t):
        n = int(input())
        ar= list(map(int, input().split()))

        solve(n,ar)


def solve(n,ar):
    ans = [int(i) for i in str(sum(ar))]

    if sum(ar)%2 != 0:
        print('YES')
        return

    else:
        for i in range(len(ans)): ##even
            if ans[i]%2 != 0: #if ar[i] is odd
                print('YES')
                return
        print('NO')

if __name__ == '__main__':
    t = int(input())

    for _ in range(t):
        n = int(input())
        ar= list(map(int, input().split()))

        solve(n,ar)


def solve(n,ar):
    ans = sum(ar)

    if ans%2 == 0:
        print('NO')
    else:
        print('YES')

    return

if __name__ == '__main__':
    t = int(input())

    for _ in range(t):
        n = int(input())
        ar= list(map(int, input().split()))

        solve(n,ar)


def solve(n,ar):

    if sum(ar)%2 != 0:
        print('YES')
        return

    else:
        for i in range(len(ar)):
            if ar[i]%2 != 0:
                print('YES')
                return
        print('NO')

if __name__ == '__main__':
    t = int(input())

    for _ in range(t):
        n = int(input())
        ar= list(map(int, input().split()))

        solve(n,ar)


def solve(n,ar):
    even = 0
    odd = 0

    if sum(ar)%2 != 0:
        print('YES')
        return

    else:
        for i in range(n): ##even
            if ar[i]%2 != 0: #if ar[i] is odd
                odd += 1
            else:
                even += 1

            if odd >= 1 and even >= 1:
                print('YES')
                return
        print('NO')

if __name__ == '__main__':
    t = int(input())

    for _ in range(t):
        n = int(input())
        ar= list(map(int, input().split()))

        solve(n,ar)


def isodd(n):
    if n%2!=0:
        return True
    else:
        return False

x=int(input())
input_storage=[]
for i in range(x):
    si=input()
    listentered=input()
    input_storage.append(listentered)

for i in input_storage:
    new=list()
    x=i.split()
    for i in x:
        count=0
        num=int(i)
        new.append(num)

    if isodd(sum(new)):
        print("YES")

    else:
        for i in new:
            if isodd(i):
                count_odd+=1
            else:
                count_even+=1
        if count_odd>0 and count_even>0:
            print("YES")
        else:
            print("No")


def isodd(n):
    if n%2!=0:
        return True
    else:
        return False

x=int(input())
input_storage=[]
for i in range(x):
    si=input()
    listentered=input()
    input_storage.append(listentered)

for i in input_storage:
    new=list()
    x=i.split()
    for i in x:
        count=0
        num=int(i)
        new.append(num)

    if isodd(sum(new)):
        print("YES")

    else:
        for i in new:
            if isodd(i)
                count_odd+=1
            else:
                count_even+=1
        if count_odd>0 and count_even>0:
            print("YES")
        else:
            print("No")


def isodd(n):
    if n%2!=0:
        return True
    else:
        return False

x=int(input())
input_storage=[]
for i in range(x):
    si=input()
    listentered=input()
    input_storage.append(listentered)

for i in input_storage:
    new=list()
    x=i.split()
    for i in x:
        count=0
        num=int(i)
        new.append(num)

    if isodd(sum(new)):
        print("YES")

    else:
        count_odd=0
        count_even=0
        for i in new:
            if isodd(i):
                count_odd+=1
            else:
                count_even+=1
        if count_odd>0 and count_even>0:
            print("YES")
        else:
            print("No")


for _ in range(int(input())):
    n=int(input())
    ar=list(map(int,input().split(" ")))
    even=False
    odd=False
    for val in ar:
        even=True if val%2==0 else odd=True
        if even and odd:
            break;
    if even and odd:
        print("YES")
    else:
        if odd and n%2!=0:
            print("YES")
        else:
            print("NO")


for _ in range(int(input())):
    n=int(input())
    ar=list(map(int,input().split(" ")))
    even=False
    odd=False
    for val in ar:
        if val%2==0:
            even=True
        else:
            odd=True
        if even and odd:
            break;
    if even and odd:
        print("YES")
    else:
        if odd and n%2!=0:
            print("YES")
        else:
            print("NO")


for _ in range(int(input())):
    n=int(input())
    ar=list(map(int,input().split(" ")))
    print("YES") if sum(ar)%2!=0 else print("NO")


for _ in range(int(input())):
	N = int(input())
	C = sum(list(map(lambda x: int(x) % 2 != 0, input().split())))
	print("YES" if (0 < C < N and N % 2 == 0) or (0 < C <= N and N % 2 != 0) else "NO")


for _ in range(int(input())):
	N = int(input())
	C = sum(list(map(lambda x: int(x) % 2 != 0, input().split())))
	print("YES" if 0 < C < N else "NO")


for _ in range(int(input())):
	input()
	print("YES" if sum(list(map(lambda x: int(x) % 2 != 0, input().split()))) % 2 != 0 else "NO")


for x in range(int(input())):
    n=int(input())
    a=list(map(int,input().split()))
    count=0
    for x in a:
        if x%2!=0:
            count+=1
    if count%2!=0:
        print("YES")
    else:
        print("NO")


for x in range(int(input())):
    n=int(input())
    a=list(map(int,input().split()))
    count=0
    for x in a:
        if x%2!=0:
            count+=1
    if count%2!=0 or (n-count)%2!=0:
        print("YES")
    else:
        print("NO")


for x in range(int(input())):
    n=int(input())
    a=list(map(int,input().split()))
    count=0
    for x in a:
        if x%2!=0:
            count+=1
    if count%2!=0:
        print("YES")
    elif count%2==0 and (n%2!=0 or n%2==0) and count<n and count>0:
        print("YES")
    else:
        print("NO")


for x in range(int(input())):
    n=int(input())
    a=list(map(int,input().split()))
    count=0
    for x in a:
        if x%2!=0:
            count+=1
    if count%2!=0 or (n-count)%2!=0:
        print("YES")
    elif count%2==0 and n%2!=0:
        print("YES")
    else:
        print("NO")


for x in range(int(input())):
    n=int(input())
    a=list(map(int,input().split()))
    count=0
    for x in a:
        if x%2!=0:
            count+=1
    if count%2!=0 or (n-count)%2!=0:
        print("YES")
    elif count%2==0 and (n%2!=0 or n%2==0) and n-count!=0 and count>0:
        print("YES")
    else:
        print("NO")


for x in range(int(input())):
    n=int(input())
    a=list(map(int,input().split()))
    count=0
    for x in a:
        if x%2!=0:
            count+=1
    if count%2!=0 or (n-count)%2!=0:
        print("YES")
    elif count%2==0 and (n%2!=0 or n%2==0) and count<n and count>0:
        print("YES")
    else:
        print("NO")


for x in range(int(input())):
    n=int(input())
    a=list(map(int,input().split()))
    count=0
    for x in a:
        if x%2!=0:
            count+=1
    if count%2!=0:
        print("YES")
    elif count%2==0  and count<n and count>0:
        print("YES")
    else:
        print("NO")


for j in range (int(input())):
    n=int(input())
    sum=0
    count=0
    l1=list(map(int,input().split()))
    for i in range(n):
        sum+=l1[i]
    if(sum%2!=0):
        print("YES")
        count=1
    if(sum%2==0):
        if(l1[0]%2==0):
         for k in range(1,n):
            if(l1[i]%2!=0):
                print("YES")
                count=1
                break
        if(l1[0]%2!=0):
         for k in range(1,n):
            if(l1[i]%2==0):
                print("YES")
                count=1
                break
    if(count==0):
       print("NO")


for j in range (int(input())):
    n=int(input())
    sum=0
    count=0
    l1=list(map(int,input().split()))
    for i in range(n):
        sum+=l1[i]
    if(sum%2!=0):
        print("YES")
        count=1
    if(sum%2==0):
        if(l1[0]%2==0):
         for k in range(1,n):
            if(l1[k]%2!=0):
                count=1
                break
        if(l1[0]%2!=0):
         for k in range(1,n):
            if(l1[k]%2==0):
                print("YES")
                count=1
                break
    if(count==0):
       print("NO")


for j in range (int(input)):
    n=int(input())
    l1=list(map(int,input().split))
    co=0
    ce=0
    sum=0
    for i in range (n):
        sum+=l1[i]
    if(sum%2!=0):
        print("YES")
    else:
        for i in range (n):
            if(l1[i]%2!=0):
                co+=1
            if(l1[i]%2==0):
                ce+=1
        if(co==0 and ce>0):
            print("NO")
        elif(ce==0 and co>0):
            print("NO")
        elif(co>0 and ce>0):
            print("YES")


for j in range (int(input())):
    n=int(input())
    sum=0
    l1=list(map(int,input().split()))
    for i in range(n):
        sum+=l1[i]
    if(sum%2!=0):
        print("yes")
    elif(l1[0]%2==0):
        for k in range(1,n):
            if(l1[i]%2!=0):
                print("yes")
                break
    elif(l1[0]%2!=0):
        for k in range(1,n):
            if(l1[i]%2==0):
                print("yes")
                break
    else:
        print("no")


for j in range (int(input())):
    n=int(input())
    sum=0
    count=0
    l1=list(map(int,input().split()))
    for i in range(n):
        sum+=l1[i]
    if(sum%2!=0):
        print("YES")
        count=1
    if(sum%2==0):
        if(l1[0]%2==0):
         for k in range(1,n):
            print("1")
            if(l1[k]%2!=0):
                count=1
                break
        if(l1[0]%2!=0):
         for k in range(1,n):
            if(l1[k]%2==0):
                print("YES")
                count=1
                break
    if(count==0):
       print("NO")


for j in range (int(input())):
    n=int(input())
    num=int(input())
    if(num<=10):
        print("-1")
        continue
    if(num%2==0):
        l=n
        while(num%2==0 and num>10):
            num//=10
            l-=1
        if(num<=10):
            print("-1")
            continue
        sum=0
        num1=num
        for i in range (l):
            sum+=num1%(10)
            num1=int(num1/(10))
        if(sum%2==0):
            print(num)
            continue
        else:
            m=l
            for i in range (l):
                if((num/(10**m))%2!=0):
                    if(l!=m and m!=0):
                        x=num%(10**(m-1))
                        y=num/(10**(m))
                        a=(10*y)+x
                        if(a<=10):
                            print("-1")
                            break
                        else:
                            print(a)
                    elif(l==m):
                        a=num%(10**(m-1))
                        if(a>10):
                            print(a)
                            break
                        else:
                            print("-1")
                            break
                    elif(m==0):
                        print("-1")
                        break
                    m-=1
    else:
        sum=0
        num1=num
        for i in range (n):
            sum+=num1%(10)
            num1=int(num1/(10))
        if(sum%2==0):
            print(num)
            continue
        else:
            m=n
            for i in range (n):
                if((num/(10**m))%2!=0):
                    if(n!=m):
                        x=num%(10**(m-1))
                        y=num/(10**(m))
                        a=(10*y)+x
                        if(a>10):
                            print(a)
                            break
                        else:
                            print("-1")
                            break
                    elif(l==m):
                        a=num%(10**(m-1))
                        if(a>10):
                            print(a)
                            break
                        else:
                            print("-1")
                    elif(m==0):
                        print("-1")
                        break
                m-=1


for j in range (int(input())):
    n=int(input())
    sum=0
    count=0
    l1=list(map(int,input().split()))
    for i in range(n):
        sum+=l1[i]
    if(sum%2!=0):
        print("YES")
        count=1
    if(sum%2==0):
        if(l1[0]%2==0):
         for k in range(1,n):
            if(l1[i]%2!=0):
                print("YES")
                count=1
                break
        if(l1[0]%2!=0):
         for k in range(1,n):
            if(l1[i]%2==0):
                print("YES")
                count=1
                break
    if(count==0):
       print("NO")
"""
5
2
2 3
4
2 2 8 8
3
3 3 3
4
5 5 5 5
4
1 1 1 1
"""


for j in range (int(input())):
    n=int(input())
    sum=0
    l1=list(map(int,input().split()))
    Count=0
    for i in range(n):
        sum+=l1[i]
    if(sum%2!=0):
        print("YES")
        count=1
    elif(Count==1):
        if(l1[0]%2==0):
         for k in range(1,n):
            if(l1[i]%2!=0):
                print("YES")
                Count=1
                break
    elif(Count==1):
        if(l1[0]%2!=0):
         for k in range(1,n):
            if(l1[i]%2==0):
                print("YES")
                break
    else:
        print("NO")


for j in range (int(input())):
    n=int(input())
    sum=0
    l1=list(map(int,input().split()))
    for i in range(n):
        sum+=l1[i]
    if(sum%2!=0):
        print("YES")
        break
    if(l1[0]%2==0):
        for k in range(1,n):
            if(l1[i]%2!=0):
                print("YES")
                break
        break
    if(l1[0]%2!=0):
        for k in range(1,n):
            if(l1[i]%2==0):
                print("YES")
                break
        break
    else:
        print("NO")


for j in range (int(input())):
    n=int(input())
    sum=0
    l1=list(map(int,input().split()))
    Count=0
    for i in range(n):
        sum+=l1[i]
    if(sum%2!=0):
        print("yes")
        count=1
    elif(Count==1):
        if(l1[0]%2==0):
         for k in range(1,n):
            if(l1[i]%2!=0):
                print("yes")
                Count=1
                break
    elif(Count==1):
        if(l1[0]%2!=0):
         for k in range(1,n):
            if(l1[i]%2==0):
                print("YES")
                break
    else:
        print("NO")


for j in range (int(input())):
    n=int(input())
    l1=list(map(int,input().split()))
    co=0
    ce=0
    sum=0
    for i in range (n):
        sum+=l1[i]
    if(sum%2!=0):
        print("YES")
    else:
        for i in range (n):
            if(l1[i]%2!=0):
                co+=1
            if(l1[i]%2==0):
                ce+=1
        if(co==0 and ce>0):
            print("NO")
        elif(ce==0 and co>0):
            print("NO")
        elif(co>0 and ce>0):
            print("YES")


for i in range(int(input())):
    n=int(input())
    c=0
    d=0
    l=list(map(int,input().split()))
    if(sum(l)%2==0):
        print("YES")
    else:
        for i in range(n):
            if(l[i]%2==0):
                c=c+1
            else:
                d=d+1
            if(c==n or d==n):
                print("NO")
            else:
                print("YES")


for i in range(int(input())):
    n=int(input())
    l=list(map(int,input().split()))
    if(sum(l)%2==0):
        print("NO")
    else:
        print("YES")


for i in range(int(input())):
    n=int(input())
    c=0
    d=0
    l=list(map(int,input().split()))
    if(sum(l)%2!=0):
        print("YES")
    else:
        for i in range(n):
            if(l[i]%2==0):
                c=c+1
            else:
                d=d+1
        if(c==n or d==n):
                print("NO")
        else:
                print("YES")


for i in range(int(input())):
    n=int(input())
    c=0
    d=0
    l=list(map(int,input().split()))
    if(sum(l)%2!==0):
        print("YES")
    else:
        for i in range(n):
            if(l[i]%2==0):
                c=c+1
            else:
                d=d+1
            if(c==n or d==l):
                print("NO")
            else:
                print("YES")


for i in range(int(input())):
    n=int(input())
    c=0
    d=0
    l=list(map(int,input().split()))
    if(sum(l)%2==0):
        print("YES")
    else:
        for i in range(n):
            if(l[i]%2==0):
                c=c+1
            else:
                d=d+1
            if(c==n or d==l):
                print("NO")
            else:
                print("YES")


n = int(input())

def f(arr):
  odd, even = 0, 0
  for x in arr:
    if x % 2: odd += 1
    else: even += 1

  if odd % 2: print("YES")
  else:
    if even:
      print("YES")
    else:
      print("NO")

for _ in range(n):
  input()
  arr = list(map(int, input().split()))
  f(arr)


n = int(input())

for _ in range(n):
    input()
    arr = list(map(int, input().split()))

    odd, even = 0, 0
    for x in arr:
        if x % 2:
            odd += 1
        else:
            even += 1

    if odd % 2:
        print("YES")
    else:
        if even % 2:
            print("YES")
        else:
            print("NO")


n = int(input())

def f(arr):
  odd, even = 0, 0
  for x in arr:
    if x % 2: odd += 1
    else: even += 1

  if odd % 2:
    print("YES")
  else:
    if odd and even:
      print("YES")
    else:
      print("NO")

for _ in range(n):
  input()
  arr = list(map(int, input().split()))
  f(arr)


#include <iostream>

using namespace std;
int main(){
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        int odd = 0;
        int even = 0;
        for(int i = 0; i < x; i++){
            int a;
            cin >> a;
            sum += a;
            if (a % 2 == 0){
                even ++;
            }
            else{
                odd ++;
            }
        }
        if ((odd > 0 && even > 0) || (sum % 2 != 0)){
            cout << "YES\n";
        }
        else
        {
            cout << "NO\n";
        }

    }
    return 0;
}


#include <iostream>
using namespace std;

int main(){
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        int odd = 0;
        int even = 0;
        for(int i = 0; i < x; i++){
            int a;
            cin >> a;
            sum += a;
            if (a % 2 == 0){
                even ++;
            }
            else{
                odd ++;
            }
        }
        if ((odd > 0 && even > 0) || (sum % 2 != 0)){
            cout << "YES\n";
        }
        else
        {
            cout << "NO\n";
        }

    }
    return 0;
}


def f():
    s = list(map(int, input().split(' ')))
    a = sum(s)
    if a % 2 != 0:
        return 'YES'
    else:
        odd = 0
        even =0
        for i in s:
            if i % 2== 0:
                even += 1
            else:
                odd += 1
        if odd > 0 and even > 0:
            return 'YES'
    return 'NO'
n = int(input())
for i in range(n):
    x = int(input())
    print(f())


def f():
    s = list(map(int, input().split(' ')))
    a = sum(s)
    if a % 2 != 0:
        return 'YES'
    else:
        odd = 0
        even =0
        for i in s:
            if odd > 0 and even >0:
                return 'YES'
            elif i % 2== 0:
                even += 1
            else:
                odd += 1
    return 'NO'
n = int(input())
for i in range(n):
    x = int(input())
    print(f())


t=int(input())
while(t):
     n=int(input())
     l=list(map(int,input().split()))
     if(sum(l)%2==0):
         print("NO")
     else:
        print("YES")
     t=t-1


t=int(input())
while(t):
     n=int(input())
     l=list(map(int,input().split()))
     odd=0
     even=0
     for i in l:
         if(i%2!=0):
             odd+=1
         else:
             even+=1
     if odd==0 or even==0 or n%2==0:
             print("NO")
     else:
        print("YES")

     t=t-1


t=int(input())
while(t):
     n=int(input())
     l=list(map(int,input().split()))
     odd=0
     even=0
     for i in l:
         if(i%2!=0):
             odd+=1
         else:
             even+=1
     if(odd==0 or even==0 or n%2==0:
             print("NO")
     else:
        print("YES")

     t=t-1


t=int(input())
while(t):
     n=int(input())
     l=list(map(int,input().split()))
     odd=0
     even=0
     for i in l:
         if(i%2!=0):
             odd+=1
         else:
             even+=1
     if(odd==0 or (even==0 and n%2==0)):
             print("NO")
     else:
        print("YES")

     t=t-1


t=int(input())
while(t):
     n=int(input())
     l=list(map(int,input().split()))
     odd=0
     even=0
     for i in l:
         if(i%2!=0):
             odd+=1
         else:
             even+=1
     if odd==0 or (even==0 and n%2==0):
             print("NO")
     else:
        print("YES")

     t=t-1


for _ in range(int(input())):
    a=int(input())
    z=0
    f=0
    p=list(map(int,input().split()))
    for i in p:
        if i%2==1:f+=1
        if i%2==0:z+=1
        if f!=0 and z!=0:break

    if f!=0:
        if a%2==1:print("YES")
        elif a%2==0 and z!=0:print("YES")
        else:print("NO")
    else:print("NO")

# My code says who am i
# I want to burn and born at this way
# In my eye there is not any things Except love ...


for _ in range(int(input())):
    input()
    x=0
    p=list(map(int,input().split()))
    for i in p:
        if i%2==1:x+=1
    print("YES" if x%2==1 else "NO")

# My code says who am i
# I want to burn and born at this way
# In my eye there is not any things Except love ...


for _ in range(int(input())):
    a=int(input())
    x=0
    p=list(map(int,input().split()))
    for i in p:
        if i%2==1:x+=1
    print("NO" if (x%2==0 and a%2==0) else "YES")

# My code says who am i
# I want to burn and born at this way
# In my eye there is not any things Except love ...


t = int(input())
for i in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    odd, even = False, False
    for i in a:
        if i%2 == 1:
            odd = True
        else:
            even = True
    if sum(a)%2 == 1 or odd and even:
        print('YES')
    else:
        print('NO')


t = int(input())
for i in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    b = set(a)
    flag = True
    if n%2 == 0:
        if len(b) == 1 and list(b)[0]%2 != 0:
            flag = False
            print('NO')
        else:
            for j in b:
                if j%2 != 0:
                    flag = False
                    print('YES')
                    break
    else:
        if len(b) == 1 and list(b)[0]%2 == 0:
            flag = False
            print('YES')
        else:
            for j in set(a):
                if j%2 != 0:
                    flag = False
                    print('YES')
                    break
    if flag == True:
        print('NO')


t = int(input())
for i in range(t):
    k = int(input())
    a = []
    a = list(map(int, input().split()))
    if sum(a)%2 == 0:
        print('NO')
    else:
        print('YES')


t = int(input())
for i in range(t):
    k = int(input())
    a = []
    a = list(map(int, input().split()))
    if sum(a)%2 == 0:
        print(sum(a))
        print('NO')
    else:
        print('YES')


t = int(input())
for i in range(t):
    k = int(input())
    a = map(int, input().split())
    if sum(a)%2 == 0:
        print('NO')
    else:
        print('YES')


for _ in range(int(input())):
    n=int(input())
    a=list(map(int,input().split()))
    e=0
    for i in range(n):
        if a[i]%2==0:
            e+=1
    if e==n:
        print("NO")
    else:
        print("YES")


for _ in range(int(input())):
    n=int(input())
    a=list(map(int,input().split()))
    e=0
    for i in range(n):
        if a[i]%2==0:
            e+=1
    if e==n or (e==0 and n%2==0):
        print("NO")
    else:
        print("YES")


n = int(input())
for i in range(n):
    k= int(input())
    L = list(map(int,input().split()))
    allEven = True
    for x in L:
        if x%2 == 1 :
            allEven = False
            break
    allOdd = True
    for x in L:
        if x%2 == 0 :
            allOdd = False
            break
    if allEven:
        print("NO")
    elif k%2==1:
        print("YES")
    elif allOdd:
        print("NO")
    else:
        print("YES")


n = input()
for i in range(n):
    k= input()
    if sum(list(input().split()))%2==0:
        print("NO")
    else:
        print("YES")


n = int(input())
for i in range(n):
    k= int(input())
    L = map(int,list(input().split()))
    allEven = True
    for x in L:
        if x%2 == 1 :
            allEven = False
            break
    allOdd = True
    for x in L:
        if x%2 == 0 :
            allOdd = False
            break
    if allEven:
        print("NO")
    elif k%2==1:
        print("YES")
    elif allOdd:
        print("NO")
    else:
        print("YES")


n = int(input())
for i in range(n):
    k= input()
    L = map(int,list(input().split()))
    allEven = True
    for x in L:
        if x%2 == 1 :
            allEven = False
            break
    allOdd = True
    for x in L:
        if x%2 == 0 :
            allOdd = False
            break
    if allEven:
        print("NO")
    elif k%2==1:
        print("YES")
    elif allOdd:
        print("NO")
    else:
        print("YES")


n = int(input())
for i in range(n):
    k= input()
    if sum(map(int,list(input().split())))%2==0:
        print("NO")
    else:
        print("YES")


#author : SanskarxRawat
import array
lst=[]
a=0
b=0
for i in range(int(input())):
 n=int(input())
 lst= list(map(int,input().strip().split()))[:n]
 for o in lst:
        if o%2!=0:  a+=1
        elif o%2==0:  b+=1
 if sum(lst)%2!=0:
    print("YES")
 elif a>=1 and b>=1:
    print("NO")
 else:
    print("NO")


#author : SanskarxRawat
for i in range(int(input())):
 n=int(input())
 lst= list(map(int,input().strip().split()))[:n]
 print("YES"if sum(lst)%2 or len(set([i%2 for i in lst]))>1 else "NO")


#author : SanskarxRawat
import array
lst=[]
a=0
b=0
for i in range(int(input())):
 n=int(input())
 lst= list(map(int,input().strip().split()))[:n]
 for o in lst:
        if o%2!=0:  a+=1
        elif o%2==0:  b+=1
 print("YES" if sum(lst)%2!=0 and a>=1 and b>=1  else "NO")


def main():
    t = int(input())
    for __ in range(t):
        n = int(input())
        s = list(map(int,input().split()))
        eve = 0
        odd = 0
        for i in s:
            if i%2 == 0:
                eve += 1
            else:
                odd += 1
        if eve == n:
            print("NO")
        elif odd  == n:
            if n%2:
                print("YES")
            else:
                print("NO")
        elif odd == eve:
            if odd % 2 == 0:
                print("NO")
            else:
                print("YES")
        else:
            a =  min(eve,odd)
            eve -= a
            odd -= a
            if odd == 0:
                print("YES")
            else:

                if odd % 2 == 0:
                    print("YES")
                else:
                    print("NO")
if __name__ == '__main__':
    main()


#include<cstdio>
#include<cstring>
#include<algorithm>
typedef long long lnt;
struct sant{
	int tranc[26];
	int len;
	int pre;
}s[2000000];
struct pnt{
	int hd;
	lnt wgt;
	int vis;
}p[2000000];
struct ent{
	int twd;
	int lst;
}e[2000000];
int cnt;
int fin;
int siz;
int n,Q;
int len;
char tmp[2000000];
void ade(int f,int t)
{
	cnt++;
	e[cnt].twd=t;
	e[cnt].lst=p[f].hd;
	p[f].hd=cnt;
	return ;
}
void Dfs(int x)
{
	for(int i=p[x].hd;i;i=e[i].lst)
	{
		int to=e[i].twd;
		Dfs(to);
		p[x].wgt+=p[to].wgt;
	}
	return ;
}
void Insert(int c)
{
	int nwp,nwq,lsp,lsq;
	nwp=++siz;
	s[nwp].len=s[fin].len+1;
	p[nwp].wgt=1;
	for(lsp=fin;lsp&&!s[lsp].tranc[c];lsp=s[lsp].pre)
		s[lsp].tranc[c]=nwp;
	if(!lsp)
		s[nwp].pre=1;
	else{
		lsq=s[lsp].tranc[c];
		if(s[lsq].len==s[lsp].len+1)
			s[nwp].pre=lsq;
		else{
			nwq=++siz;
			s[nwq]=s[lsq];
			s[nwq].len=s[lsp].len+1;
			s[lsq].pre=s[nwp].pre=nwq;
			while(s[lsp].tranc[c]==lsq)
			{
				s[lsp].tranc[c]=nwq;
				lsp=s[lsp].pre;
			}
		}
	}
	fin=nwp;
	return ;
}
int main()
{
	fin=++siz;
	scanf("%s",tmp+1);
	len=strlen(tmp+1);
	for(int i=1;i<=len;i++)
		Insert(tmp[i]-'a');
	for(int i=2;i<=siz;i++)
		ade(s[i].pre,i);
	Dfs(1);
	scanf("%d",&Q);
	while(Q--)
	{
		scanf("%s",tmp);
		len=strlen(tmp);
		int ln=len<<1;
		lnt ans=0;
		int root=1,l=0;
		for(int j=0;j<ln;j++)
		{
			int i=j%len;
			int c=tmp[i]-'a';
			while(root&&!s[root].tranc[c])
				root=s[root].pre,l=s[root].len;
			root=s[root].tranc[c];
			if(!root)
				root=1,l=0;
			else{
				l++;
				while(s[s[root].pre].len>=len&&s[root].pre)
					root=s[root].pre,l=s[root].len;
				if(p[root].vis!=Q+1&&l>=len)
				{
					ans+=p[root].wgt;
					p[root].vis=Q+1;
				}
			}
		}
		printf("%I64d\n",ans);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10 ;
int sz, last ;
struct node {
    int len, link, nxt[26] ;
}st[maxn] ;
char s[maxn] ;
int head[maxn], to[maxn], nxt[maxn], tot = 1 ;
int f[maxn] ;
bool vis[maxn], flag[maxn] ;
void sam_init () {
    st[0].len = 0; st[0].link = -1 ;
    sz ++; last = 0 ;
}
void insert (int c) {
    int cur = sz ++; flag[cur] = 1 ;
    st[cur].len = st[last].len + 1 ;
    int p = last ;
    while (p != -1 && !st[p].nxt[c]) {
        st[p].nxt[c] = cur; p = st[p].link ;
    }
    if (p == -1) {
        st[cur].link = 0; last = cur; return ;
    }
    int q = st[p].nxt[c] ;
    if (st[p].len + 1 == st[q].len) {
        st[cur].link = q ;
    } else {
        int clone = sz ++ ;
        st[clone].len = st[p].len + 1 ;
        for (int i = 0; i < 26; i ++) st[clone].nxt[i] = st[q].nxt[i] ;
        st[clone].link = st[q].link ;
        while (p != -1 && st[p].nxt[c] == q) {
            st[p].nxt[c] = clone; p = st[p].link ;
        }
        st[cur].link = st[q].link = clone ;
    }
    last = cur ;
}
void addEdge (int u, int v) {
    to[++ tot] = v; nxt[tot] = head[u]; head[u] = tot ;
}
int dfs (int v) {
    int res = 0 ;
    for (int i = head[v]; i; i = nxt[i])
        res += dfs (to[i]) ;
    return f[v] = res + flag[v] ;
}
int main() {
    sam_init () ;
    scanf("%s", s + 1) ;
    int len = strlen (s + 1) ;
    for (int i = 1; i <= len; i ++) insert (s[i] - 'a') ;
    for (int i = 1; i < sz; i ++) addEdge (st[i].link, i) ;
    dfs (0) ;
    int n ;
    scanf("%d", &n) ;
    for (int i = 1; i <= n; i ++) {
        memset (vis, 0, sizeof vis) ;
        scanf("%s", s + 1) ;
        len = strlen (s + 1) ;
        for (int j = len + 1; j < 2 * len; j ++) s[j] = s[j - len] ;
        int u = 0, l = 0, ans = 0 ;
        for (int j = 1; j <= len * 2 - 1; j ++) {
            while (u != 0 && !st[u].nxt[s[j] - 'a']) {
                u = st[u].link; l = st[u].len ;
            }
            if (st[u].nxt[s[j] - 'a']) {
                u = st[u].nxt[s[j] - 'a'], l ++ ;
            } else {
                u = 0; l = 0 ;
            }
            if (l > len) {
                while (st[st[u].link].len >= len) {
                    u = st[u].link; l = st[u].len ;
                }
            }
            if (l >= len && !vis[u]) {
                vis[u] = 1 ;
                ans += f[u] ;
            }
        }
        printf("%d\n", ans) ;
    }
    return 0 ;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#define il inline
#define ri register
#define ll long long
#define lb long double
#define dkp 10007
#define Size 2000050
#define noip 20190816170251
using namespace std;
ll base[Size];
bool is[Size];
char s[Size],t[Size];
int prime[Size],pt,a[Size];
struct umap{
	struct iter{
		iter* next;ll j;
	}ar[Size],*head[Size];
	int gzy,art;
	il void init(int mod){
		memset(head,art=0,gzy*sizeof(iter*)),gzy=mod;
	}
	il void insert(ll j){
		head[j%gzy]=&(ar[++art]={head[j%gzy],j});
	}
	il iter*find(ll j){
		for(iter*i(head[j%gzy]);i;i=i->next)
			if(i->j==j)return i;return NULL;
	}
}U;
struct sam{
	struct state{
		bool is_clone;
		int tran[26],len,link,minlen;
	}s[Size];
	int last=1,tot=1,a1[Size],a2[Size];
	il void extend(int c){
		int cur(++tot),p(last);s[last=cur].len=s[p].len+1;
		while(p&&!s[p].tran[c])s[p].tran[c]=cur,p=s[p].link;
		if(p){
			int q(s[p].tran[c]);
			if(s[q].len==s[p].len+1)s[cur].link=q;
			else{int clone(++tot);
				(s[clone]=s[q]).len=s[p].len+1,s[cur].link=s[q].link=clone;
				while(s[p].tran[c]==q)s[p].tran[c]=clone,p=s[p].link;
				s[clone].is_clone=1;
			}
		}else s[cur].link=1;
	}
	il void init(){
		for(int i(1);i<=tot;++i)++a1[s[i].len];
		for(int i(1);i<=s[last].len;++i)a1[i]+=a1[i-1];
		for(int i(1);i<=tot;++i)a2[a1[s[i].len]--]=i;
		memset(a1,0,s[last].len+1<<2);
		for(int i(tot),j;i;--i)
			j=a2[i],a1[s[j].link]+=a1[j]+=!s[j].is_clone,
				s[j].minlen=s[s[j].link].len+1;
	}
	il void query(char*t){
		int n1(strlen(t+1)),p(1),i,j;
		U.init(a[n1]);ll H(0),ans(0);
		for(i=1,j=0;i<=n1;++i){H=(H*dkp+t[i])%noip;
			while(p>1&&!s[p].tran[t[i]-97])j=s[p=s[p].link].len;
			if(s[p].tran[t[i]-97])p=s[p].tran[t[i]-97],++j;
		}for(i=1;i<=n1;++i){
			if(!U.find(H))U.insert(H),ans+=j==n1?a1[p]:0;
			H=(((H-t[i]*base[n1-1])%noip*dkp+t[i])%noip+noip)%noip;
			while(p>1&&!s[p].tran[t[i]-97])j=s[p=s[p].link].len;
			if(s[p].tran[t[i]-97])p=s[p].tran[t[i]-97],++j;
			if(j>n1){j=n1;if(s[p].minlen>n1)p=s[p].link;}
		}printf("%lld\n",ans);
	}
}S;
il void prepare();
int main(){
	int n;scanf("%s%d",s+1,&n),prepare();
	for(int i(1);s[i];++i)S.extend(s[i]-97);S.init();
	for(int i(1);i<=n;++i)scanf("%s",t+1),S.query(t);
	return 0;
}
il void prepare(){
	is[1]=base[0]=1;
	for(int i(1);i<Size;++i)
		base[i]=base[i-1]*dkp%noip;
	for(int i(2),j;i<Size;++i){
		base[i]=base[i-1]*dkp%noip;
		if(!is[i])prime[++pt]=i;
		for(j=1;j<=pt&&prime[j]*i<Size;++j)
			if(is[i*prime[j]]=1,!(i%prime[j]))break;
	}for(int i(Size-1),j(Size-1);i;--i){if(!is[i])j=i;a[i]=j;}
}


// default code for competitive programming
// ver 3.1415 {{{

// Includes
#include <bits/stdc++.h>

// Defines
#define NAME(x) #x
#define SZ(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, e) for( int i = 0 ; i < (e) ; i++ )
#define ITER(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define REP(i, s, e) for(int i = (s); i <= (e); i++)
#define REPD(i, s, e) for(int i = (s); i >= (e); i--)
#define IOS ios_base::sync_with_stdio( 0 )
#define DEBUG 1
#define fst first
#define snd second
#define PB push_back
#ifdef ONLINE_JUDGE
#define FILE( fn ) \
    freopen(fn".in","r",stdin); \
freopen(fn".out","w",stdout);
#else
#define FILE( fn )
#endif

#ifdef AKAI
#define debug( ... ) fprintf( stderr , __VA_ARGS__ )
#else
#define debug( ... )
#endif

using namespace std;

// Typedefs
typedef double real;
typedef long long ll;
typedef pair<ll, int> pli;
typedef tuple<ll, int> tli;
typedef pair<int, int> pii;
typedef tuple<int, int> tii;
typedef unsigned long long ull;

// Some common const.
const double EPS = 1e-8;
const double Pi = acos(-1);

// Equal for double
bool inline equ(double a, double b)
{return fabs(a - b) < EPS;}

int _R( int& x ) { return scanf( "%d" , &x ); }
int _R( ll& x ) { return scanf( "%" PRId64 , &x ); }
int _R( double& x ) { return scanf( "%lf" , &x ); }
int _R( char* s ) { return scanf( "%s" , s ); }

int R() { return 0; }

  template< typename T1 , typename... T2 >
int R( T1& x , T2&... tail )
{
  int tmp = _R( x );
  return tmp + R( tail... );
}

  template< typename Iter , typename F >
inline void out( Iter s , Iter e , F of )
{
  bool flag = 0;
  for( Iter it = s ; it != e ; it++ )
  {
    if( flag ) printf( " " );
    else flag = 1;
    of( *it );
  }
  puts( "" );
}

// }}}
// start ~~QAQ~~

const int MAXM = 2000010;
struct SAM{
  int tot, root, lst, mom[MAXM], mx[MAXM];
  int acc[MAXM], nxt[MAXM][33];
  int newNode(){
    int res = ++tot;
    fill(nxt[res], nxt[res]+33, 0);
    mom[res] = mx[res] = acc[res] = 0;
    return res;
  }
  void init(){
    tot = 0;
    root = newNode();
    mom[root] = 0, mx[root] = 0;
    lst = root;
  }
  void push(int c){
    int p = lst;
    int np = newNode();
    mx[np] = mx[p]+1;
    for(; p && nxt[p][c] == 0; p = mom[p])
      nxt[p][c] = np;
    if(p == 0) mom[np] = root;
    else{
      int q = nxt[p][c];
      if(mx[p]+1 == mx[q]) mom[np] = q;
      else{
        int nq = newNode();
        mx[nq] = mx[p]+1;
        for(int i = 0; i < 33; i++)
          nxt[nq][i] = nxt[q][i];
        mom[nq] = mom[q];
        mom[q] = nq;
        mom[np] = nq;
        for(; p && nxt[p][c] == q; p = mom[p])
          nxt[p][c] = nq;
      }
    }
    lst = np;
  }
  void print(){
    REP(i, 1, tot){
      printf("node %d :\n", i);
      printf("mx %d, mom %d\n", mx[i], mom[i]);
      REP(j, 1, 26) if(nxt[i][j])
        printf("nxt %c %d\n", 'a'+j-1, nxt[i][j]);
      puts("---------------------------");
    }
  }
  void push(char *str){
    for(int i = 0; str[i]; i++)
      push(str[i]-'a'+1);
  }
  bool end[ MAXM ];
  void dfs( int u ) {
    if( end[ u ] ) {
      acc[ u ]++;
    }
    REP( c , 1 , 26 ) if( nxt[ u ][ c ] ) {
      if( !acc[ nxt[ u ][ c ] ] )
        dfs( nxt[ u ][ c ] );
      acc[ u ] += acc[ nxt[ u ][ c ] ];
    }
  }
  void yutruli() {
    int now = lst;
    while( now ) {
      end[ now ] = 1;
      now = mom[ now ];
    }
    dfs( root );
  }
} sam;

const int MAXL = 1e6+10;

char ip[ MAXL ] , qry[ MAXL ];

inline void calc() {
  R( qry );
  int len = strlen( qry );
  int np = sam.root;
  int cl = 0;
  FOR( i , len ) {
    int c = qry[ i ]-'a'+1;
    while( np && !sam.nxt[ np ][ c ] ) {
      np = sam.mom[ np ];
      cl = min( cl , sam.mx[ np ] );
    }
    if( np ) np = sam.nxt[ np ][ c ] , cl++;
    else np = sam.root , cl = 0;
  }
  int ans = 0;
  set<int> vis;
  FOR( i , len ) {
    if( cl >= len ) {
      if( !vis.count( np ) ) {
        ans += sam.acc[ np ];
        vis.insert( np );
      }
    }
    int c = qry[ i ]-'a'+1;
    while( np && !sam.nxt[ np ][ c ] ) {
      np = sam.mom[ np ];
      cl = min( cl , sam.mx[ np ] );
    }
    while( np && sam.mx[ sam.mom[ np ] ] >= len ) {
      np = sam.mom[ np ];
      cl = min( cl , sam.mx[ np ] );
    }
    if( np ) np = sam.nxt[ np ][ c ] , cl++;
    else np = sam.root , cl = 0;
  }
  printf( "%d\n" , ans );
}

int main() {
  R( ip );
  sam.init();
  sam.push( ip );
  sam.yutruli();
  int q; R( q );
  while( q-- ) {
    calc();
  }
}

// ntuj - duv4ytmf5e0yh4ksky0gq


#include<bits/stdc++.h>
using namespace std;
#define MAXNODE 2000005
#define SIGMA 26
struct node{
    node *fail,*ch[SIGMA];
    int len,cnt,vis;
    node() {fail=0;len=cnt=vis=0;memset(ch,0,sizeof ch);}
}mem[MAXNODE], *root, *last;

int str_cnt;

struct SuffixAutomaton{
    int size;
    inline int idx(char c){return c-'a';}
    inline void init(){
        size = 0;
        root = last = &mem[0];
    }
    // main SAM
    inline void add(char c){
        c = idx(c);
        node *pre = last;
        node *now = &mem[++size];
        now->len = pre->len+1;
        while(pre && !pre->ch[c]){
            pre->ch[c] = now;
            pre = pre->fail;
        }
        if(!pre) now->fail = root;
        else{
            node *q = pre->ch[c];
            if(q->len == pre->len+1) now->fail = q;
            else
            {
                node *nq = &mem[++size];
                nq->len = pre->len+1;
                memcpy(nq->ch, q->ch, sizeof(q->ch));
                nq->fail = q->fail;
                q->fail = now->fail = nq;
                while(pre && pre->ch[c] == q){
                    pre->ch[c] = nq;
                    pre=pre->fail;
                }
            }
        }
        last = now;
    }
    // solve problem
    int C[MAXNODE], ord[MAXNODE];
    void build_cnt(char* s,int n){
        for(int i = 0; i <= size; i++) C[mem[i].len]++;
        for(int i = 1; i <= size; i++) C[i] += C[i-1];
        for(int i = 0; i <= size; i++) ord[--C[mem[i].len]] = i;
        node* now = root;
        for(int i = 0; i < n; i++){
            int c = idx(s[i]);
            now = now->ch[c];
            now->cnt = 1;
        }
        for(int i = size; i >= 0; i--){
            now = &mem[ord[i]];
            if(now->fail) now->fail->cnt += now->cnt;
        }
    }

    int solve(char* s){
        str_cnt++;
        int n = strlen(s), cnt = 0, ans = 0;
        node* now = root;
        for(int i = 0; i < n-1; i++){
            int c = idx(s[i]);
            if(now->ch[c]) cnt++, now = now->ch[c];
            else{
                while(now && !now->ch[c]) now = now->fail;
                if(!now) cnt=0, now=root;
                else cnt = now->len+1, now = now->ch[c];
            }
            while(cnt >= n/2 && now->fail && now->fail->len >= n/2){
                cnt = now->fail->len;
                now = now->fail;
            }
            if(cnt >= n/2 && now->vis != str_cnt){
                ans += now->cnt;
                now->vis = str_cnt;
            }
        }
        return ans;
    }
}SAM;

char s[MAXNODE];
int main(){
    SAM.init();
    scanf("%s",s);
    int n=strlen(s);
    for(int i=0;i<n;i++){
        SAM.add(s[i]);
    }
    SAM.build_cnt(s,n);
    int t;
    scanf("%d",&t);
    while(t--){
        scanf("%s",s);
        n=strlen(s);
        for(int i=n;i<n*2;i++) s[i]=s[i-n];
        s[n*2]=0;
        printf("%d\n",SAM.solve(s));
    }
}

// ntuj - gjqplsh9hdtxdzeh8brw3


#include<bits/stdc++.h>
using namespace std;
#define MAXNODE 2000005
#define SIGMA 26
struct node{
    node *fail,*ch[SIGMA];
    int len,cnt,vis;
    node() {fail=0;len=cnt=vis=0;memset(ch,0,sizeof ch);}
}mem[MAXNODE], *root, *last;

int str_cnt;

struct SuffixAutomaton{
    int size;
    inline int idx(char c){return c-'a';}
    inline void init(){
        size = 0;
        root = last = &mem[0];
    }
    // main SAM
    inline void add(char c){
        c = idx(c);
        node *pre = last;
        node *now = &mem[++size];
        now->len = pre->len+1;
        while(pre && !pre->ch[c]){
            pre->ch[c] = now;
            pre = pre->fail;
        }
        if(!pre) now->fail = root;
        else{
            node *q = pre->ch[c];
            if(q->len == pre->len+1) now->fail = q;
            else
            {
                node *nq = &mem[++size];
                nq->len = pre->len+1;
                memcpy(nq->ch, q->ch, sizeof(q->ch));
                nq->fail = q->fail;
                q->fail = now->fail = nq;
                while(pre && pre->ch[c] == q){
                    pre->ch[c] = nq;
                    pre=pre->fail;
                }
            }
        }
        last = now;
    }
    // solve problem
    int C[MAXNODE], ord[MAXNODE];
    void build_cnt(char* s,int n){
        for(int i = 0; i <= size; i++) C[mem[i].len]++;
        for(int i = 1; i <= size; i++) C[i] += C[i-1];
        for(int i = 0; i <= size; i++) ord[--C[mem[i].len]] = i;
        node* now = root;
        for(int i = 0; i < n; i++){
            int c = idx(s[i]);
            now = now->ch[c];
            now->cnt = 1;
        }
        for(int i = size; i >= 0; i--){
            now = &mem[ord[i]];
            if(now->fail) now->fail->cnt += now->cnt;
        }
    }

    int solve(char* s){
        str_cnt++;
        int n = strlen(s), cnt = 0, ans = 0;
        node* now = root;
        for(int i = 0; i < n-1; i++){
            int c = idx(s[i]);
            if(now->ch[c]) cnt++, now = now->ch[c];
            else{
                while(now && !now->ch[c]) now = now->fail;
                if(!now) cnt=0, now=root;
                else cnt = now->len+1, now = now->ch[c];
            }
            while(cnt >= n/2 && now->fail && now->fail->len >= n/2){
                cnt = now->fail->len;
                now = now->fail;
            }
            if(cnt >= n/2 && now->vis != str_cnt){
                ans += now->cnt;
                now->vis = str_cnt;
            }
        }
        return ans;
    }
}SAM;

char s[MAXNODE];
int main(){
    SAM.init();
    scanf("%s",s);
    int n=strlen(s);
    for(int i=0;i<n;i++){
        SAM.add(s[i]);
    }
    SAM.build_cnt(s,n);
    int t;
    scanf("%d",&t);
    while(t--){
        scanf("%s",s);
        n=strlen(s);
        for(int i=n;i<n*2;i++) s[i]=s[i-n];
        s[n*2]=0;
        printf("%d\n",SAM.solve(s));
    }
}

// ntuj - 9klooduvzndnwyuuxtjfq


#include<bits/stdc++.h>
using namespace std;
#define MAXNODE 2000005
#define SIGMA 26
struct node{
    node *fail,*ch[SIGMA];
    int len,cnt,vis;
    node() {fail=0;len=cnt=vis=0;memset(ch,0,sizeof ch);}
}mem[MAXNODE], *root, *last;

int str_cnt;

struct SuffixAutomaton{
    int size;
    inline int idx(char c){return c-'a';}
    inline void init(){
        size = 0;
        root = last = &mem[0];
    }
    // main SAM
    inline void add(char c){
        c = idx(c);
        node *pre = last;
        node *now = &mem[++size];
        now->len = pre->len+1;
        while(pre && !pre->ch[c]){
            pre->ch[c] = now;
            pre = pre->fail;
        }
        if(!pre) now->fail = root;
        else{
            node *q = pre->ch[c];
            if(q->len == pre->len+1) now->fail = q;
            else
            {
                node *nq = &mem[++size];
                nq->len = pre->len+1;
                memcpy(nq->ch, q->ch, sizeof(q->ch));
                nq->fail = q->fail;
                q->fail = now->fail = nq;
                while(pre && pre->ch[c] == q){
                    pre->ch[c] = nq;
                    pre=pre->fail;
                }
            }
        }
        last = now;
    }
    // solve problem
    int C[MAXNODE], ord[MAXNODE];
    void build_cnt(char* s,int n){
        for(int i = 0; i <= size; i++) C[mem[i].len]++;
        for(int i = 1; i <= size; i++) C[i] += C[i-1];
        for(int i = 0; i <= size; i++) ord[--C[mem[i].len]] = i;
        node* now = root;
        for(int i = 0; i < n; i++){
            int c = idx(s[i]);
            now = now->ch[c];
            now->cnt = 1;
        }
        for(int i = size; i >= 0; i--){
            now = &mem[ord[i]];
            if(now->fail) now->fail->cnt += now->cnt;
        }
    }

    int solve(char* s){
        str_cnt++;
        int n = strlen(s), cnt = 0, ans = 0;
        node* now = root;
        for(int i = 0; i < n-1; i++){
            int c = idx(s[i]);
            if(now->ch[c]) cnt++, now = now->ch[c];
            else{
                while(now && !now->ch[c]) now = now->fail;
                if(!now) cnt=0, now=root;
                else cnt = now->len+1, now = now->ch[c];
            }
            if(cnt >= n/2 && now->vis != str_cnt){
                ans += now->cnt;
                now->vis = str_cnt;
            }
        }
        return ans;
    }
}SAM;

char s[MAXNODE];
int main(){
    SAM.init();
    scanf("%s",s);
    int n=strlen(s);
    for(int i=0;i<n;i++){
        SAM.add(s[i]);
    }
    SAM.build_cnt(s,n);
    int t;
    scanf("%d",&t);
    while(t--){
        scanf("%s",s);
        n=strlen(s);
        for(int i=n;i<n*2;i++) s[i]=s[i-n];
        s[n*2]=0;
        printf("%d\n",SAM.solve(s));
    }
}
// ntuj - 38q64n6729ym3r5w2mmzc


#include<bits/stdc++.h>
using namespace std;
const int maxnode=2000000+5;
const int SIGMA_SIZE=26;
struct Node
{
    Node *fail,*ch[SIGMA_SIZE];
    int Max,End,vis;
    Node() {fail=0;Max=vis=End=0;memset(ch,0,sizeof ch);}
} mem[maxnode],*root,*last;
struct SuffixAutomaton
{
    int size,scnt;
    inline int idx(char c) {return c-'a';}
    inline void init() {size=scnt=0;root=last=&mem[0];}
    inline void add(char c)
    {
        c=idx(c);
        Node *p=last;
        Node *np=&mem[++size];np->Max=p->Max+1;
        while(p && !p->ch[c]) p->ch[c]=np,p=p->fail;
        if(!p) np->fail=root;
        else
        {
            Node *q=p->ch[c];
            if(q->Max==p->Max+1) np->fail=q;
            else
            {
                Node *nq=&mem[++size];nq->Max=p->Max+1;
                memcpy(nq->ch,q->ch,sizeof(q->ch));
                nq->fail=q->fail;
                q->fail=np->fail=nq;
                while(p && p->ch[c]==q) p->ch[c]=nq,p=p->fail;
            }
        }
        last=np;
    }
    int C[maxnode],ord[maxnode];
    void topo_cal(char* s,int n)
    {
        for(int i=0;i<=size;i++) C[mem[i].Max]++;
        for(int i=1;i<=size;i++) C[i]+=C[i-1];
        for(int i=0;i<=size;i++) ord[--C[mem[i].Max]]=i;
        Node* now=root;
        for(int i=0;i<n;i++)
        {
            int c=idx(s[i]);
            now=now->ch[c];
            now->End=1;
        }
        for(int i=size;i>=0;i--)
        {
            now=&mem[ord[i]];
            if(now->fail) now->fail->End+=now->End;
        }
    }
    inline void solve(char* s)
    {
        scnt++;
        int n=strlen(s),cnt=0,ans=0;
        Node* now=root;
        for(int i=0;i<n-1;i++)
        {
            int c=idx(s[i]);
            if(now->ch[c]) cnt++,now=now->ch[c];
            else
            {
                while(now && !now->ch[c]) now=now->fail;
                if(!now) cnt=0,now=root;
                else cnt=now->Max+1,now=now->ch[c];
            }
            while(cnt>=n/2 && now->fail && now->fail->Max>=n/2) cnt=now->fail->Max,now=now->fail;
            if(cnt>=n/2 && now->vis!=scnt) ans+=now->End,now->vis=scnt;
        }
        printf("%d\n",ans);
    }
}SAM;
const int maxlen=1000000+5;
char s[maxlen*2];
int main()
{
    SAM.init();
    scanf("%s",s);
    int n=strlen(s),T;
    for(int i=0;i<n;i++) SAM.add(s[i]);
    SAM.topo_cal(s,n);
    scanf("%d",&T);
    while(T--)
    {
        scanf("%s",s);
        n=strlen(s);
        for(int i=0;i<n;i++) s[i+n]=s[i];
        s[n*2]='\0';
        SAM.solve(s);
    }
}
// ntuj - bxz930lill2fjewg4gq60


// whats 1000 minus 7 ?
// I'm bad, and that's good. I will never be good, and that's not bad. There's no one I'd rather be than me.
// unless someone like you cares a whole awful lot nothing is going to get better. it's not
#include <bits/stdc++.h>
using namespace std;
inline int in(){int32_t x ; scanf("%d",&x) ; return x ; }
inline long long lin(){long long x ; scanf("%lld",&x) ; return x ;}
inline string get(){char ch[2000010] ; scanf("%s",ch) ; return ch;}
const int MAX_LG = 21;
//#define int long long
#define X first
#define Y second
#define endl "\n"
#define Mp make_pair
typedef pair<int , int > pii;
typedef long double ld;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pii> vii;
const int maxn = 2e6 + 10;
const int maxm = 1e5 + 10;
const int base = 29;
const int mod = 1e9 + 7;
const int base2 = 31;
const int mod2 = 1e9 + 9;
const int INF = 2e18 + 100;
const int SQ = 317;
int last;
int sz = 1;
int len[maxn];
int link[maxn];
int nxt[maxn][26];
inline void addLetter(int c)
{
    int p = last;
    last = sz ++;
    len[last] = len[p] + 1;
    for ( ; p != -1 && nxt[p][c] == 0 ; p = link[p]){
        nxt[p][c] = last;
    }
    if (p == -1){
        link[last] = 0;
        return;
    }
    int q = nxt[p][c];
    if (len[q] == len[p] + 1)
    {
        link[last] = q;
        return;
    }
    int cl = sz  ++ ;
    for (int j = 0 ; j < 26 ; j ++)
        nxt[cl][j] = nxt[q][j];
    link[cl] = link[q];
    len[cl] = len[p] + 1;
    link[q] = link[last] = cl;
    for ( ; nxt[p][c] == q ; p = link[p])
        nxt[p][c] = cl;
}
int cnt[maxn];
bool mark[maxn];
inline void calc(int state)
{
    if (mark[state]) return ;
    mark[state] = true;
    for (int i = 0 ; i < 26 ; i ++){
        if (nxt[state][i]){
            calc(nxt[state][i]);
            cnt[state] += cnt[nxt[state][i]];
        }
    }
}
int kmp[maxn];
inline int repeat(string &t)
{
    int tmp = 0;
    for (int i = 1 ; i < t.size() ; i ++)
    {
        while (tmp && t[tmp] != t[i]) tmp = kmp[tmp - 1];
        if (t[tmp] == t[i]) tmp ++;
        kmp[i] = tmp ;
    }
    int v = (int)t.size() - kmp[(int)t.size() - 1];
    if ((int)t.size() % v == 0)
        return v;
    return (int)t.size();
}
inline int Count(string &t)
{
    int ret = 0;
    int state = 0 , ln = 0;
    int lim = repeat(t);
    for (int i = 0 ; i < (int)t.size() + lim - 1 ; i ++)
    {
        int cur = i % ((int)t.size());
        while (state != -1 && nxt[state][t[cur] - 'a'] == 0){
            state = link[state];
            if (state != -1)
                ln = len[state];
        }
        if (state == -1)
            state = ln = 0;
        else
            state = nxt[state][t[cur] - 'a'] , ln ++;
        if (ln == t.size())
        {
            ret += cnt[state];
            ln --;
            while (link[state] != -1 && len[link[state]] >= ln)
                state = link[state];
        }
    }
    return ret;
}
int32_t main()
{
    link[0] = -1;
    string s = get();
    for (int i = 0 ; i < s.size() ; i ++)
        addLetter(s[i] - 'a');
    for (int p = last ; p != -1 ; p = link[p]) cnt[p] ++;
    calc(0);
    int n = in();
    for (int i = 0 ; i < n ; i ++)
    {
        string t = get();
        printf("%d\n",Count(t));

    }
}


// whats 1000 minus 7 ?
// I'm bad, and that's good. I will never be good, and that's not bad. There's no one I'd rather be than me.
// unless someone like you cares a whole awful lot nothing is going to get better. it's not
#include <bits/stdc++.h>
using namespace std;
inline int in(){int32_t x ; scanf("%d",&x) ; return x ; }
inline long long lin(){long long x ; scanf("%lld",&x) ; return x ;}
inline string get(){char ch[2000010] ; scanf("%s",ch) ; return ch;}
const int MAX_LG = 21;
//#define int long long
#define X first
#define Y second
#define endl "\n"
#define Mp make_pair
typedef pair<int , int > pii;
typedef long double ld;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pii> vii;
const int maxn = 2e6 + 10;
const int maxm = 1e5 + 10;
const int base = 29;
const int mod = 1e9 + 7;
const int base2 = 31;
const int mod2 = 1e9 + 9;
const int INF = 2e18 + 100;
const int SQ = 317;
int last;
int sz = 1;
int len[maxn];
int link[maxn];
int nxt[maxn][26];
inline void addLetter(int c)
{
    int p = last;
    last = sz ++;
    len[last] = len[p] + 1;
    for ( ; p != -1 && nxt[p][c] == 0 ; p = link[p]){
        nxt[p][c] = last;
    }
    if (p == -1){
        link[last] = 0;
        return;
    }
    int q = nxt[p][c];
    if (len[q] == len[p] + 1)
    {
        link[last] = q;
        return;
    }
    int cl = sz  ++ ;
    for (int j = 0 ; j < 26 ; j ++)
        nxt[cl][j] = nxt[q][j];
    link[cl] = link[q];
    len[cl] = len[p] + 1;
    link[q] = link[last] = cl;
    for ( ; nxt[p][c] == q ; p = link[p])
        nxt[p][c] = cl;
}
int cnt[maxn];
bool mark[maxn];
inline void calc(int state)
{
    if (mark[state]) return ;
    mark[state] = true;
    for (int i = 0 ; i < 26 ; i ++){
        if (nxt[state][i]){
            calc(nxt[state][i]);
            cnt[state] += cnt[nxt[state][i]];
        }
    }
}
int kmp[maxn];
inline int repeat(string &t)
{
    int tmp = 0;
    for (int i = 1 ; i < t.size() ; i ++)
    {
        while (tmp && t[tmp] != t[i]) tmp = kmp[tmp - 1];
        if (t[tmp] == t[i]) tmp ++;
        kmp[i] = tmp ;
    }
    int v = (int)t.size() - kmp[(int)t.size() - 1];
    if ((int)t.size() % v == 0)
        return v;
    return (int)t.size();
}
inline int Count(string &t)
{
    int ret = 0;
    int state = 0 , ln = 0;
    int lim = repeat(t);
    for (int i = 0 ; i < (int)t.size() + lim - 1 ; i ++)
    {
        int cur = i % ((int)t.size());
        while (state != -1 && nxt[state][t[cur] - 'a'] == 0){
            state = link[state];
            if (state != -1)
                ln = len[state];
        }
        if (state == -1)
            state = ln = 0;
        else
            state = nxt[state][t[cur] - 'a'] , ln ++;
        if (ln == t.size())
        {
            ret += cnt[state];
            ln --;
            while (len[link[state]] >= ln)
                state = link[state];

        }
    }
    return ret;
}
int32_t main()
{
    link[0] = -1;
    string s = get();
    for (int i = 0 ; i < s.size() ; i ++)
        addLetter(s[i] - 'a');
    for (int p = last ; p != -1 ; p = link[p]) cnt[p] ++;
    calc(0);
    int n = in();
    for (int i = 0 ; i < n ; i ++)
    {
        string t = get();
        printf("%d\n",Count(t));

    }
}


// whats 1000 minus 7 ?
// I'm bad, and that's good. I will never be good, and that's not bad. There's no one I'd rather be than me.
// unless someone like you cares a whole awful lot nothing is going to get better. it's not
#include <bits/stdc++.h>
using namespace std;
inline int in(){int32_t x ; scanf("%d",&x) ; return x ; }
inline long long lin(){long long x ; scanf("%lld",&x) ; return x ;}
inline string get(){char ch[2000010] ; scanf("%s",ch) ; return ch;}
const int MAX_LG = 21;
//#define int long long
#define X first
#define Y second
#define endl "\n"
#define Mp make_pair
typedef pair<int , int > pii;
typedef long double ld;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pii> vii;
const int maxn = 2e6 + 10;
const int maxm = 1e5 + 10;
const int base = 29;
const int mod = 1e9 + 7;
const int base2 = 31;
const int mod2 = 1e9 + 9;
const int INF = 2e18 + 100;
const int SQ = 317;
int last;
int sz = 1;
int len[maxn];
int link[maxn];
int nxt[maxn][26];
inline void addLetter(int c)
{
    int p = last;
    last = sz ++;
    len[last] = len[p] + 1;
    for ( ; p != -1 && nxt[p][c] == 0 ; p = link[p]){
        nxt[p][c] = last;
    }
    if (p == -1){
        link[last] = 0;
        return;
    }
    int q = nxt[p][c];
    if (len[q] == len[p] + 1)
    {
        link[last] = q;
        return;
    }
    int cl = sz  ++ ;
    for (int j = 0 ; j < 26 ; j ++)
        nxt[cl][j] = nxt[q][j];
    link[cl] = link[q];
    len[cl] = len[p] + 1;
    link[q] = link[last] = cl;
    for ( ; nxt[p][c] == q ; p = link[p])
        nxt[p][c] = cl;
}
int cnt[maxn];
bool mark[maxn];
inline void calc(int state)
{
    if (mark[state]) return ;
    mark[state] = true;
    for (int i = 0 ; i < 26 ; i ++){
        if (nxt[state][i]){
            calc(nxt[state][i]);
            cnt[state] += cnt[nxt[state][i]];
        }
    }
}
int kmp[maxn];
inline int repeat(string &t)
{
    int tmp = 0;
    for (int i = 1 ; i < t.size() ; i ++)
    {
        while (tmp && t[tmp] != t[i]) tmp = kmp[tmp - 1];
        if (t[tmp] == t[i]) tmp ++;
        kmp[i] = tmp ;
    }
    int v = (int)t.size() - kmp[(int)t.size() - 1];
    if ((int)t.size() % v == 0)
        return v;
    return (int)t.size();
}
inline int Count(string &t)
{
    int ret = 0;
    int state = 0 , ln = 0;
    int lim = repeat(t);
    for (int i = 0 ; i < (int)t.size() + lim - 1 ; i ++)
    {
        int cur = i % ((int)t.size());
        while (state != -1 && nxt[state][t[cur] - 'a'] == 0){
            state = link[state];
            if (state != -1)
                ln = len[state];
        }
        if (state == -1)
            state = ln = 0;
        else
            state = nxt[state][t[cur] - 'a'] , ln ++;
        if (ln == t.size())
        {
            ret += cnt[state];
            ln --;
            assert(len[link[state]] <= ln);

            if (len[link[state]] == ln) state = link[state];

        }
    }
    return ret;
}
int32_t main()
{
    link[0] = -1;
    string s = get();
    for (int i = 0 ; i < s.size() ; i ++)
        addLetter(s[i] - 'a');
    for (int p = last ; p != -1 ; p = link[p]) cnt[p] ++;
    calc(0);
    int n = in();
    for (int i = 0 ; i < n ; i ++)
    {
        string t = get();
        cout << Count(t) << "\n";
    }
}


// whats 1000 minus 7 ?
// I'm bad, and that's good. I will never be good, and that's not bad. There's no one I'd rather be than me.
// unless someone like you cares a whole awful lot nothing is going to get better. it's not
#include <bits/stdc++.h>
using namespace std;
inline int in(){int32_t x ; scanf("%d",&x) ; return x ; }
inline long long lin(){long long x ; scanf("%lld",&x) ; return x ;}
inline string get(){char ch[2000010] ; scanf("%s",ch) ; return ch;}
const int MAX_LG = 21;
//#define int long long
#define X first
#define Y second
#define endl "\n"
#define Mp make_pair
typedef pair<int , int > pii;
typedef long double ld;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pii> vii;
const int maxn = 2e6 + 10;
const int maxm = 1e5 + 10;
const int base = 29;
const int mod = 1e9 + 7;
const int base2 = 31;
const int mod2 = 1e9 + 9;
const int INF = 2e18 + 100;
const int SQ = 317;
int last;
int sz = 1;
int len[maxn];
int link[maxn];
int nxt[maxn][26];
inline void addLetter(int c)
{
    int p = last;
    last = sz ++;
    len[last] = len[p] + 1;
    for ( ; p != -1 && nxt[p][c] == 0 ; p = link[p]){
        nxt[p][c] = last;
    }
    if (p == -1){
        link[last] = 0;
        return;
    }
    int q = nxt[p][c];
    if (len[q] == len[p] + 1)
    {
        link[last] = q;
        return;
    }
    int cl = sz  ++ ;
    for (int j = 0 ; j < 26 ; j ++)
        nxt[cl][j] = nxt[q][j];
    link[cl] = link[q];
    len[cl] = len[p] + 1;
    link[q] = link[last] = cl;
    for ( ; nxt[p][c] == q ; p = link[p])
        nxt[p][c] = cl;
}
int cnt[maxn];
bool mark[maxn];
inline void calc(int state)
{
    if (mark[state]) return ;
    mark[state] = true;
    for (int i = 0 ; i < 26 ; i ++){
        if (nxt[state][i]){
            calc(nxt[state][i]);
            cnt[state] += cnt[nxt[state][i]];
        }
    }
}
int kmp[maxn];
inline int repeat(string &t)
{
    int tmp = 0;
    for (int i = 1 ; i < t.size() ; i ++)
    {
        while (tmp && t[tmp] != t[i]) tmp = kmp[tmp - 1];
        if (t[tmp] == t[i]) tmp ++;
        kmp[i] = tmp ;
    }
    int v = (int)t.size() - kmp[(int)t.size() - 1];
    if ((int)t.size() % v == 0)
        return v;
    return (int)t.size();
}
inline int Count(string &t)
{
    int ret = 0;
    int state = 0 , ln = 0;
    int lim = repeat(t);
    for (int i = 0 ; i < (int)t.size() + lim - 1 ; i ++)
    {
        int cur = i % ((int)t.size());
        while (state != -1 && nxt[state][t[cur] - 'a'] == 0){
            state = link[state];
            if (state != -1)
                ln = len[state];
        }
        if (state == -1)
            state = ln = 0;
        else
            state = nxt[state][t[cur] - 'a'] , ln ++;
        if (ln == t.size())
        {
            ret += cnt[state];
            ln --;
            assert(len[link[state]] <= ln);
            if (len[link[state]] == ln) state = link[state];
        }
    }
    return ret;
}
int32_t main()
{
    link[0] = -1;
    string s = get();
    for (int i = 0 ; i < s.size() ; i ++)
        addLetter(s[i] - 'a');
    for (int p = last ; p != -1 ; p = link[p]) cnt[p] ++;
    calc(0);
    int n = in();
    for (int i = 0 ; i < n ; i ++)
    {
        string t = get();
//        cout << Count(t) << "\n";
        printf("%d\n",Count(t));

    }
}


#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<map>
#include<vector>
#define maxn 6000005
#define re register
#define LL long long
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
std::map<int,int> son[maxn];
struct E{int v,nxt;}e[maxn];
int n,lst=1,cnt=1,num,m;
int len[maxn],head[maxn],sz[maxn],deep[maxn],vis[maxn],fa[maxn];
inline void add(int x,int y) {e[++num].v=y;e[num].nxt=head[x];head[x]=num;}
void dfs(int x) {for(re int i=head[x];i;i=e[i].nxt) deep[e[i].v]=deep[x]+1,dfs(e[i].v),sz[x]+=sz[e[i].v];}
int st[1000005],top;
std::vector<int> a[100005];
int L[100005];
char S[1000005];
inline void ins(int c,int o,int t)
{
	int f=lst,p=++cnt; lst=p;
	len[p]=len[f]+1; if(!o) sz[p]=1;
	if(o&&t) a[o].push_back(p);
	while(f&&!son[f][c]) son[f][c]=p,f=fa[f];
	if(!f) {fa[p]=1;return;}
	int x=son[f][c];
	if(len[f]+1==len[x]) {fa[p]=x;return;}
	int y=++cnt;
	len[y]=len[f]+1,fa[y]=fa[x],fa[x]=fa[p]=y;
	for(std::map<int,int>::iterator it=son[x].begin();it!=son[x].end();it++) son[y].insert(*it);
	while(f&&son[f][c]==x) son[f][c]=y,f=fa[f];
}
inline int find(int x,int li) {while(len[fa[x]]>=li) x=fa[x];return x;}
int main()
{
	scanf("%s",S+1),n=strlen(S+1);scanf("%d",&m);
	for(re int i=1;i<=n;i++) ins(S[i]-'a',0,0);
	for(re int i=1;i<=m;i++)
	{
		scanf("%s",S+1);L[i]=strlen(S+1);lst=1;
		for(re int j=1;j<L[i];j++) ins(S[j]-'a',i,0);ins(S[L[i]]-'a',i,1);
		for(re int j=1;j<L[i];j++) ins(S[j]-'a',i,1);
	}
	for(re int i=2;i<=cnt;i++) add(fa[i],i);deep[1]=1;dfs(1);
	for(re int i=1;i<=m;i++)
	{
		int ans=0;top=0;
		for(re int j=0;j<a[i].size();j++)
		{
			int t=find(a[i][j],L[i]);
			if(vis[t]) continue;
			st[++top]=t;ans+=sz[t];vis[t]=1;
		}
		printf("%d\n",ans);
		for(re int j=1;j<=top;j++) vis[st[j]]=0;
	}
	return 0;
}