/*Made by Shivam Solanki*/
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
#define endl '\n'
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef queue<int> qii;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
#define all(x) x.begin(),x.end()
#define rep(i,k,n) for (int i = k; i < n; ++i)
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i)
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;
double pi = 2 * acos(0.0);

void solve(){
    int n,k;
    cin>>n>>k;
    vi marked(n,0);
    int max_spread=(k*2)+1;
    vi ans;
    if(n>=2*max_spread){
        int l=0;
        int r=2*k;
        ans.pb(k+1);
        rep(i,l,r+1){
            marked[i]=1;
        }
    }
    rep(i,0,n){
        if(marked[i]==0){
            int l=max(0,i-k);
            int r=min(n-1,i+k);
            bool f=0;
            // cout<<l<<' '<<r<<'\n';
            if(marked[l]==0 and marked[r]==0){
                ans.pb(i+1);
                rep(i,l,r+1){
                    marked[i]=1;
                }
            }
        }
    }
    bool f=0;
    rep(i,0,n){
        if(marked[i]==0){
            f=1;
            break;
        }
    }
    if(f){
        marked=vi(n,0);
        ans.clear();
        rep(i,0,n){
            if(marked[i]==0){
                int l=max(0,i-k);
                int r=min(n-1,i+k);
                bool f=0;
                // cout<<l<<' '<<r<<'\n';
                if(marked[l]==0 and marked[r]==0){
                    ans.pb(i+1);
                    rep(i,l,r+1){
                        marked[i]=1;
                    }
                }
            }
        }
    }
    cout<<ans.size()<<'\n';
    rep(i,0,ans.size()){
        cout<<ans[i]<<' ';
    }
}

int main(){
    // #ifndef ONLINE_JUDGE
        // freopen("input.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
    // #endif
    fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
int main()
{
	ll n, k;
	cin >> n >> k;
	ll razryv = 2 * k + 1;
	ll ans = 1e9, start;
	for (int i = 1; i <= k + 1; i++)
	{
		ll now = i, ops = 1;
		while (now + k < n)
		{
			now += razryv;
			ops++;
		}
		if(now + k >= n)
			if (ops < ans)
				ans = ops, start = i;
	}
	cout << ans << '\n';
	for (int i = start; i <= n; i += 0)
	{
		cout << i << ' ';
		i += razryv;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
int main()
{
	ll n, k;
	cin >> n >> k;
	ll global_ll_ans = 1e9;
	vector<ll>global_ans;
	if (k * 2 + 1 >= n)
	{
		cout << (n + 1) / 2;
		return 0;
	}
	for (int z = 1; z <= k + 1; z++)//z - ����� ������ ��������������
	{
		vector<bool>a(n + 1);
		vector<int>var;
		var.push_back(z);
		ll first_bad = z;
		for (int i = z; i <= z + k; i++)
		{
			a[i] = true;
		}
		first_bad = z + k + 1;
		ll kol = 0;
		bool b = 0;
		while (find(a.begin() + z, a.end(), 0) != a.end())
		{
			for (int i = first_bad; i < first_bad + k && i < n; i++)
			{
				a[i] = true;
			}
			var.push_back(first_bad + k);
			if (first_bad + k > n)
			{
				b = 1;
				break;
			}
			a[first_bad + k] = true;
			first_bad = first_bad + 1 + k;
			for (int i = first_bad; i < first_bad + k && i <= n; i++)
			{
				a[i] = true;
			}
			first_bad = first_bad + k;
		}
		if (b == 1)
			continue;
		if (var.size() < global_ll_ans)
		{
			global_ans.clear();
			for (int i = 0; i < var.size(); i++)
			{
				global_ans.push_back(var[i]);
			}
			global_ll_ans = global_ans.size();
		}
	}
	cout << global_ans.size() << '\n';
	for (int i = 0; i < global_ans.size(); i++)
	{
		cout << global_ans[i] << ' ';
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
int main()
{
	ll n, k;
	cin >> n >> k;
	ll global_ll_ans = 1e9;
	vector<ll>global_ans;
	if (k * 2 + 1 >= n)
	{
		cout << (n + 1) / 2;
		return 0;
	}
	for (int z = 1; z <= k + 1; z++)//z - ����� ������ ��������������
	{
		vector<bool>a(n + 1);
		vector<int>var;
		var.push_back(z);
		ll first_bad = z;
		for (int i = z; i <= z + k; i++)
		{
			a[i] = true;
		}
		first_bad = z + k + 1;
		ll kol = 0;
		bool b = 0;
		while (find(a.begin() + z, a.end(), 0) != a.end())
		{
			for (int i = first_bad; i < first_bad + k; i++)
			{
				a[i] = true;
			}
			var.push_back(first_bad + k);
			if (first_bad + k > n)
			{
				b = 1;
				break;
			}
			a[first_bad + k] = true;
			first_bad = first_bad + 1 + k;
			for (int i = first_bad; i < first_bad + k && i <= n; i++)
			{
				a[i] = true;
			}
		}
		if (b == 1)
			continue;
		if (var.size() < global_ll_ans)
		{
			global_ans.clear();
			for (int i = 0; i < var.size(); i++)
			{
				global_ans.push_back(var[i]);
			}
			global_ll_ans = global_ans.size();
		}
	}
	cout << global_ans.size() << '\n';
	for (int i = 0; i < global_ans.size(); i++)
	{
		cout << global_ans[i] << ' ';
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
int main()
{
	ll n, k;
	cin >> n >> k;
	vector<ll>a(n);
	ll last_good = k;
	for (int i = 0; i <= k; i++)
		a[i] = 1;
	vector<ll>ans;
	ans.push_back(1);
	while (find(a.begin(), a.end(), 0) != a.end())
	{
		ans.push_back(last_good + 2 + k);
		for (int i = last_good + 1; i <= last_good + k * 2 + 1 && i < n; i++)
		{
			a[i] = 1;
		}
		last_good += k - 1;
	}
	cout << ans.size() << '\n';
	for (int i = 0; i < ans.size(); i++)
		cout << ans[i] << ' ';
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
int main()
{
	ll n, k;
	cin >> n >> k;
	vector<ll>a(n);
	ll last_good = k + 1;
	if (k * 2 + 1 >= n)
	{
		cout << (n + 1) / 2;
		return 0;
	}
	for (int i = 0; i <= k; i++)
		a[i] = 1;
	vector<ll>ans;
	ans.push_back(1);
	while (find(a.begin(), a.end(), 0) != a.end())
	{
		ans.push_back(last_good + 1 + k);
		for (int i = last_good; i <= last_good + k * 2 && i < n; i++)
		{
			a[i] = 1;
		}
		last_good += k;
	}
	cout << ans.size() << '\n';
	for (int i = 0; i < ans.size(); i++)
		cout << ans[i] << ' ';
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
int main()
{
	ll n, k;
	cin >> n >> k;
	ll global_ll_ans = 1e9;
	vector<ll>global_ans;
	for (int z = 1; z <= k + 1; z++)//z - ����� ������ ��������������
	{
		vector<bool>a(n + 1);
		vector<int>var;
		var.push_back(z);
		ll first_bad = z;
		for (int i = z; i <= z + k; i++)
		{
			a[i] = true;
		}
		first_bad = z + k + 1;
		ll kol = 0;
		while (find(a.begin() + z, a.end(), 0) != a.end())
		{
			for (int i = first_bad; i < first_bad + k; i++)
			{
				a[i] = true;
			}
			var.push_back(first_bad + k);
			a[first_bad + k] = true;
			first_bad = first_bad + 1 + k;
			for (int i = first_bad; i < first_bad + k && i <= n; i++)
			{
				a[i] = true;
			}
		}
		if (var.size() < global_ll_ans)
		{
			global_ans.clear();
			for (int i = 0; i < var.size(); i++)
			{
				global_ans.push_back(var[i]);
			}
			global_ll_ans = global_ans.size();
		}
	}
	cout << global_ans.size() << '\n';
	for (int i = 0; i < global_ans.size(); i++)
	{
		cout << global_ans[i] << ' ';
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
int main()
{
	ll n, k;
	cin >> n >> k;
	vector<ll>a(n);
	ll last_good = k;
	if (k * 2 + 1 >= n)
	{
		cout << k + 1;
		return 0;
	}
	for (int i = 0; i <= k; i++)
		a[i] = 1;
	vector<ll>ans;
	ans.push_back(1);
	while (find(a.begin(), a.end(), 0) != a.end())
	{
		ans.push_back(last_good + 2 + k);
		for (int i = last_good + 1; i <= last_good + k * 2 + 1 && i < n; i++)
		{
			a[i] = 1;
		}
		last_good += k - 1;
	}
	cout << ans.size() << '\n';
	for (int i = 0; i < ans.size(); i++)
		cout << ans[i] << ' ';
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
int main()
{
	ll n, k;
	cin >> n >> k;
	ll razryv = 2 * k + 1;
	ll ans = 1e9, start;
	for (int i = 1; i <= k + 1; i++)
	{
		ll now = i, ops = 1;
		while (now + k < n)
		{
			now += razryv;
			ops++;
		}
		if(now + k >= n)
			if (ops < ans)
				ans = ops, start = i;
	}
	for (int i = start; i <= n; i += 0)
	{
		cout << i << ' ';
		i += razryv;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
int main()
{
	ll n, k;
	cin >> n >> k;
	ll global_ll_ans = 1e9;
	vector<ll>global_ans;
	if (k * 2 + 1 >= n)
	{
		cout << (n + 1) / 2;
		return 0;
	}
	for (int z = 1; z <= k + 1; z++)//z - ����� ������ ��������������
	{
		vector<bool>a(n + 1);
		vector<int>var;
		var.push_back(z);
		ll first_bad = z;
		for (int i = z; i <= z + k; i++)
		{
			a[i] = true;
		}
		first_bad = z + k + 1;
		ll kol = 0;
		bool b = 0;
		while (find(a.begin() + z, a.end(), 0) != a.end())
		{
			for (int i = first_bad; i < first_bad + k; i++)
			{
				a[i] = true;
			}
			var.push_back(first_bad + k);
			if (first_bad + k > n)
			{
				b = 1;
				break;
			}
			a[first_bad + k] = true;
			first_bad = first_bad + 1 + k;
			for (int i = first_bad; i < first_bad + k && i <= n; i++)
			{
				a[i] = true;
			}
			first_bad = first_bad + k;
		}
		if (b == 1)
			break;
		if (var.size() < global_ll_ans)
		{
			global_ans.clear();
			for (int i = 0; i < var.size(); i++)
			{
				global_ans.push_back(var[i]);
			}
			global_ll_ans = global_ans.size();
		}
	}
	cout << global_ans.size() << '\n';
	for (int i = 0; i < global_ans.size(); i++)
	{
		cout << global_ans[i] << ' ';
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long, long long> pl;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef map<long long, long long> ml;
typedef set<long long> sl;
typedef map<int, int> mi;
typedef set<int> si;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define REPI(i, a, b) for(ll i = a; i < b; ++i)
#define REPJ(j, a, b) for(ll j = a; j < b; ++j)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    ll mn = n;
    vi vec;
    REPJ(j, 0, k+1){
        vi t;
        ll cnt = 0;
        for (int i = j; i < n; ++i){
            ++cnt;
            t.PB(i);
            if (i < n-1-2*k || i >= n-1-k)
                i += 2*k;
            else {
                cnt = n;
                break;
            }
        }
        if (cnt < mn)
            vec = t;
        mn = min(mn, cnt);
    }
    cout << mn << endl;
    if (k != 0){
        for(auto v: vec){
            cout << v+1 << " ";
        }
    } else {
        REPI(i, 1, n+1)
            cout << i << " ";
    }
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long, long long> pl;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef map<long long, long long> ml;
typedef set<long long> sl;
typedef map<int, int> mi;
typedef set<int> si;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define REPI(i, a, b) for(ll i = a; i < b; ++i)
#define REPJ(j, a, b) for(ll j = a; j < b; ++j)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    ll mn = n;
    vi vec;
    REPJ(j, 0, k+1){
        vi t;
        ll cnt = 0;
        for (int i = j; i < n; ++i){
            ++cnt;
            t.PB(i);
            if (i < n-1-2*k || i >= n-1-k)
                i += 2*k;
            else {
                cnt = n;
                break;
            }
        }
        if (cnt < mn)
            vec = t;
        mn = min(mn, cnt);
    }

    if (k != 0 && k != n){
        cout << mn << endl;
        for(auto v: vec){
            cout << v+1 << " ";
        }
    } else if (k == 0){
        cout << mn << endl;
        REPI(i, 1, n+1)
            cout << i << " ";
    } else if (k == n){
        cout << 1 << endl;
        cout << n;
    }
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long, long long> pl;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef map<long long, long long> ml;
typedef set<long long> sl;
typedef map<int, int> mi;
typedef set<int> si;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define REPI(i, a, b) for(ll i = a; i < b; ++i)
#define REPJ(j, a, b) for(ll j = a; j < b; ++j)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    ll mn = n;
    vi vec;
    REPJ(j, 0, k+1){
        vi t;
        ll cnt = 0;
        for (int i = j; i < n; ){
            ++cnt;
            t.PB(i);
            if (i < n-1-2*k || i >= n-1-k)
                i += 2*k+1;
            else {
                cnt = n;
                break;
            }
        }
        if (cnt < mn)
            vec = t;
        mn = min(mn, cnt);
    }
    cout << mn << endl;
    for(auto v: vec){
        cout << v+1 << " ";
    }
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long, long long> pl;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef map<long long, long long> ml;
typedef set<long long> sl;
typedef map<int, int> mi;
typedef set<int> si;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define REPI(i, a, b) for(ll i = a; i < b; ++i)
#define REPJ(j, a, b) for(ll j = a; j < b; ++j)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    ll mn = n;
    vi vec;
    REPJ(j, 0, k+1){
        vi t;
        ll cnt = 0;
        for (int i = j; i < n; ++i){
            ++cnt;
            t.PB(i);
            if (i < n-1-2*k || i >= n-1-k)
                i += 2*k;
            else {
                cnt = n;
                break;
            }
        }
        if (cnt < mn)
            vec = t;
        mn = min(mn, cnt);
    }

    if (k != 0 && k < n){
        cout << mn << endl;
        for(auto v: vec){
            cout << v+1 << " ";
        }
    } else if (k == 0){
        cout << mn << endl;
        REPI(i, 1, n+1)
            cout << i << " ";
    } else if (k >= n){
        cout << 1 << endl;
        cout << n;
    }
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long, long long> pl;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef map<long long, long long> ml;
typedef set<long long> sl;
typedef map<int, int> mi;
typedef set<int> si;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define REPI(i, a, b) for(ll i = a; i < b; ++i)
#define REPJ(j, a, b) for(ll j = a; j < b; ++j)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    ll mn = n;
    vi vec;
    REPJ(j, 0, k+1){
        vi t;
        ll cnt = 0;
        for (int i = j; i < n; ++i){
            ++cnt;
            t.PB(i);
            if (i < n-1-2*k || i >= n-1-k)
                i += 2*k;
            else {
                cnt = n;
                break;
            }
        }
        if (cnt < mn)
            vec = t;
        mn = min(mn, cnt);
    }

    if (k != 0 && k != n){
        cout << mn << endl;
        for(auto v: vec){
            cout << v+1 << " ";
        }
    } else if (k == 0){
        cout << mn << endl;
        REPI(i, 1, n+1)
            cout << i << " ";
    } else if (k >= n){
        cout << 1 << endl;
        cout << n;
    }
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long, long long> pl;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef map<long long, long long> ml;
typedef set<long long> sl;
typedef map<int, int> mi;
typedef set<int> si;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define REPI(i, a, b) for(ll i = a; i < b; ++i)
#define REPJ(j, a, b) for(ll j = a; j < b; ++j)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    ll mn = n;
    vi vec;
    REPJ(j, 0, k+1){
        vi t;
        ll cnt = 0;
        for (int i = j; i < n; ){
            ++cnt;
            t.PB(i);
            if (i < n-1-2*k || i >= n-1-k)
                i += 2*k+1;
            else {
                cnt = n;
                break;
            }
        }
        if (cnt < mn)
            vec = t;
        mn = min(mn, cnt);
    }
    cout << mn << endl;
    for(auto v: vec){
        cout << v << " ";
    }
    cout << endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

long n,k,kk,m,ans,fst,fnl;

int main()
{
	scanf("%ld%ld",&n,&k);
	kk=2*k+1;
	ans=n/kk;
	if(n%kk!=0) ans++;
		printf("%ld\n",ans);
	m=n%kk;
	//printf("m=%ld kk=%ld\n",m,kk);
	if(m==0)
	{
		printf("%ld",k+1);
		for(long i=k+1+kk;i<=n;i+=kk)
		{
			printf(" %ld",i);
		}
		return 0;
	}

//	if(m%2==1)
//	{
//		fst=(m-1)/2+1;
//		fnl=n-fst+1;
//	}
//	if(m%2==0)
	{
		fst=(m/2)+1;
		fnl=(m+1)/2;
		fnl=n-fnl+1;
	}
	printf("%ld",fst);
	for(long i=1;i<=(ans-2);i++)
	{
		printf(" %ld",fst+i*kk);
	}
	printf(" %ld\n",fnl);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

long n,k,kk,m,ans,fst,fnl;

int main()
{
	scanf("%ld%ld",&n,&k);
	kk=2*k+1;
	ans=n/kk;
	if(n%kk!=0) ans++;
		printf("%ld\n",ans);
	m=n%kk;
	if(ans==1)
		{
			if(n%2==1)
				printf("%ld\n",n/2+(n%2));
			return 0;
		}
	//printf("m=%ld kk=%ld\n",m,kk);
	if(m==0)
	{
		printf("%ld",k+1);
		for(long i=k+1+kk;i<=n;i+=kk)
		{
			printf(" %ld",i);
		}
		return 0;
	}

//	if(m%2==1)
//	{
//		fst=(m-1)/2+1;
//		fnl=n-fst+1;
//	}
//	if(m%2==0)
	{
		fst=(m/2)+1;
		fnl=(m+1)/2;
		fnl=n-fnl+1;
	}
	printf("%ld",fst);
	for(long i=1;i<=(ans-2);i++)
	{
		printf(" %ld",fst+i*kk);
	}
	printf(" %ld\n",fnl);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

long n,k,kk,m,ans,fst,fnl;

int main()
{
	scanf("%ld%ld",&n,&k);
	kk=2*k+1;
	ans=n/kk;
	if(n%kk!=0) ans++;
		printf("%ld\n",ans);
	m=n%kk;
	if(ans==1)
		{
			if(n%2==1)
				printf("%ld\n",n/2+1);
			return 0;
		}
	//printf("m=%ld kk=%ld\n",m,kk);
	if(m==0)
	{
		printf("%ld",k+1);
		for(long i=k+1+kk;i<=n;i+=kk)
		{
			printf(" %ld",i);
		}
		return 0;
	}

//	if(m%2==1)
//	{
//		fst=(m-1)/2+1;
//		fnl=n-fst+1;
//	}
//	if(m%2==0)
	{
		fst=(m/2)+1;
		fnl=(m+1)/2;
		fnl=n-fnl+1;
	}
	printf("%ld",fst);
	for(long i=1;i<=(ans-2);i++)
	{
		printf(" %ld",fst+i*kk);
	}
	printf(" %ld\n",fnl);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

long n,k,kk,m,ans,fst,fnl;

int main()
{
	scanf("%ld%ld",&n,&k);
	kk=2*k+1;
	ans=n/kk;
	if(n%kk!=0) ans++;
		printf("%ld\n",ans);
	m=n%kk;
	//printf("m=%ld kk=%ld\n",m,kk);
	if(m==0)
	{
		printf("%ld",k+1);
		for(long i=k+1+kk;i<=n;i+=kk)
		{
			printf(" %ld",i);
		}
		return 0;
	}

//	if(m%2==1)
//	{
//		fst=(m-1)/2+1;
//		fnl=n-fst+1;
//	}
//	if(m%2==0)
	{
		fst=(m/2)+1;
		fnl=(m+1)/2;
		fnl=n-fnl+1;
	}
	printf("%ld",fst);
	for(long i=1;i<=(ans-2);i++)
	{
		printf(" %ld",fst+i*kk);
	}
	printf("%ld\n",fnl);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

long n,k,kk,m,ans,fst,fnl;

int main()
{
	scanf("%ld%ld",&n,&k);
	kk=2*k+1;
	ans=n/kk;
	if(n%kk!=0) ans++;
		printf("%ld\n",ans);
	m=n%kk;
	if(ans==1)
		{
				printf("%ld\n",n/2+1);
			return 0;
		}
	//printf("m=%ld kk=%ld\n",m,kk);
	if(m==0)
	{
		printf("%ld",k+1);
		for(long i=k+1+kk;i<=n;i+=kk)
		{
			printf(" %ld",i);
		}
		return 0;
	}

//	if(m%2==1)
//	{
//		fst=(m-1)/2+1;
//		fnl=n-fst+1;
//	}
//	if(m%2==0)
	{
		fst=(m/2)+1;
		fnl=(m+1)/2;
		fnl=n-fnl+1;
	}
	printf("%ld",fst);
	for(long i=1;i<=(ans-2);i++)
	{
		printf(" %ld",fst+i*kk);
	}
	printf(" %ld\n",fnl);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

long n,k,kk,m,ans,fst,fnl;

int main()
{
	scanf("%ld%ld",&n,&k);
	kk=2*k+1;
	ans=n/kk;
	if(n%kk!=0) ans++;
		printf("%ld\n",ans);
	m=n%kk;
	//printf("m=%ld kk=%ld\n",m,kk);
	if(m==0)
	{
		printf("%ld",k+1);
		for(long i=k+1+kk;i<=n;i+=kk)
		{
			printf(" %ld",i);
		}
		return 0;
	}

//	if(m%2==1)
//	{
//		fst=(m-1)/2+1;
//		fnl=n-fst+1;
//	}
//	if(m%2==0)
	{
		fst=(m/2)+1;
		fnl=(m+1)/2;
		fnl=n-fnl+1;
	}
	printf("%ld %ld",fst,fnl);
	for(long i=1;i<=(ans-2);i++)
	{
		printf(" %ld",fst+i*kk);
	}

	return 0;
}


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

int main()
{
    int n,k;
    int j=0,temp;
    int save[1010]={0};
    scanf("%d %d",&n,&k);
    int work=2*k+1;

    temp=n/work;
    temp=(temp+1)*work-n;

    if(temp%2 == 0)
        temp--;

    for(int i=temp/2+1;i<=n;i+=work)
    {
        save[j++]=i;
    }
    if(j==0)
    {
        printf("%d\n%d",1,1);
    }
    else
    {
        printf("%d\n",j);
        for(int i=0;i<j;i++)
        {
            printf("%d ",save[i]);
        }
    }

    return 0;
}


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

int main()
{
    int n,k;
    int j=0;
    int save[1010]={0};
    scanf("%d %d",&n,&k);
    for(int i=k+1;i<=n;i+=2*k)
    {
        save[j++]=i;
    }
    if(j==0)
    {
        printf("%d\n%d",1,1);
    }
    else
    {
        printf("%d\n",j);
        for(int i=0;i<j;i++)
        {
            printf("%d ",save[i]);
        }
    }

    return 0;
}


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

int main()
{
    int n,k;
    int j=0;
    int save[1010]={0};
    scanf("%d %d",&n,&k);
    int temp=n/k;
    temp=(temp+1)*k-n;
    for(int i=temp/2+1;i<=n;i+=2*k+1)
    {
        save[j++]=i;
    }
    if(j==0)
    {
        printf("%d\n%d",1,1);
    }
    else
    {
        printf("%d\n",j);
        for(int i=0;i<j;i++)
        {
            printf("%d ",save[i]);
        }
    }

    return 0;
}


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

int main()
{
    int n,k;
    int j=0,temp;
    int save[1010]={0};
    scanf("%d %d",&n,&k);
    if(k!=0)
    {
        temp=n/k;
        temp=(temp+1)*k-n;
    }
    else temp=1;
    for(int i=temp/2+1;i<=n;i+=2*k+1)
    {
        save[j++]=i;
    }
    if(j==0)
    {
        printf("%d\n%d",1,1);
    }
    else
    {
        printf("%d\n",j);
        for(int i=0;i<j;i++)
        {
            printf("%d ",save[i]);
        }
    }

    return 0;
}


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

int main()
{
    int n,k;
    int j=0,temp;
    int save[1010]={0};
    scanf("%d %d",&n,&k);
    int work=2*k+1;
    if(k!=0)
    {
        temp=n/work;
        temp=(temp+1)*work-n;
    }
    else temp=1;

    for(int i=temp/2+1;i<=n;i+=work)
    {
        save[j++]=i;
    }
    if(j==0)
    {
        printf("%d\n%d",1,1);
    }
    else
    {
        printf("%d\n",j);
        for(int i=0;i<j;i++)
        {
            printf("%d ",save[i]);
        }
    }

    return 0;
}


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

int main()
{
    int n,k;
    int j=0,temp;
    int save[1010]={0};
    scanf("%d %d",&n,&k);
    int work=2*k+1;

    temp=n/work;
    temp=(temp+1)*work-n;
    //����!!!!!!!!!!!!!!!!!!!!!
    for(int i=k+1-temp/2;i<=n;i+=work)  //���i����ʼֵ��Ҫ�ú��㰡������
    {
        save[j++]=i;
    }
    if(j==0)
    {
        printf("%d\n%d",1,1);
    }
    else
    {
        printf("%d\n",j);
        for(int i=0;i<j;i++)
        {
            printf("%d ",save[i]);
        }
    }

    return 0;
}


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

int main()
{
    int n,k;
    int j=0,temp;
    int save[1010]={0};
    scanf("%d %d",&n,&k);
    if(k!=0)
    {
        temp=n/k;
        temp=(temp+1)*k-n;
    }
    else temp=1;
    if(temp == k)
        temp+=2;
    for(int i=temp/2+1;i<=n;i+=2*k+1)
    {
        save[j++]=i;
    }
    if(j==0)
    {
        printf("%d\n%d",1,1);
    }
    else
    {
        printf("%d\n",j);
        for(int i=0;i<j;i++)
        {
            printf("%d ",save[i]);
        }
    }

    return 0;
}


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

int main()
{
    int n,k;
    int j=0,temp;
    int save[1010]={0};
    scanf("%d %d",&n,&k);
    int work=2*k+1;

    temp=n/work;
    temp=(temp+1)*work-n;
    if(n%work == 0)
        temp=0;    //����!!!!!!!!!!!!!!!!!!!!!

    for(int i=k+1-temp/2;i<=n;i+=work)  //���i����ʼֵ��Ҫ�ú��㰡������
    {
        save[j++]=i;
    }
    if(j==0)
    {
        printf("%d\n%d",1,1);
    }
    else
    {
        printf("%d\n",j);
        for(int i=0;i<j;i++)
        {
            printf("%d ",save[i]);
        }
    }

    return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	if (n <= k) {
		cout << 1 << '\n' << 1;
		return 0;
	}
	int i = 1, cnt = 0;
	vector<int> ans;
	while (i + k <= n) {
		++cnt;
		ans.push_back(i + k);
		i += ((2 * k) + 1);
	}
	if (i <= n) {
		++cnt;
		ans.push_back(i + 1);
	}
	cout << cnt << '\n';
	for (int i: ans)
		cout << i << ' ';
	return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	if (k == 0) {
		cout << n << '\n';
		for (int i = 1; i <= n; ++i)
			cout << i << ' ';
		return 0;
	}
	int ans = (n / (k + k + 1)) + (int)(n % (k + k + 1) != 0);
	cout << ans << '\n';
	for (int i = 0; i < ans; ++i)
		cout << i * (k + k) + i + 1 << ' ';
	return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	if (n <= k) {
		cout << 1 << '\n' << 1;
		return 0;
	}
	int i = 1, cnt = 0;
	vector<int> ans;
	while (i + k <= n) {
		++cnt;
		ans.push_back(i + k);
		i += ((2 * k) + 1);
	}
	if (i < n) {
		++cnt;
		ans.push_back(i + 1);
	}
	cout << cnt << '\n';
	for (int i: ans)
		cout << i << ' ';
	return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	if (n <= k)
		return cout << "1\n1", 0;
	if (k == 0) {
		cout << n << '\n';
		for (int i = 1; i <= n; ++i)
			cout << i << ' ';
		return 0;
	}

	int cnt = n, pos = -1;
	for (int i = 1; i <= k + 1; ++i) {
		int c = n - (i + k - 1);
		if (c % (k + k + 1) == 0 || c % (k + k + 1) >= k + 1) {
			int tmp = c / (k + k + 1) + 1 + (int)(c % (k + k + 1) != 0);
			if (tmp < cnt) {
				cnt = tmp;
				pos = i;
			}
		}
	}
	cout << cnt << '\n';
	for (;pos <= n; pos += (k + k + 1), --cnt) {
		cout << pos << ' ';
	}
	if (cnt)
		cout << pos - k;
	return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	if (n <= k)
		return cout << "1\n1", 0;
	if (k == 0) {
		cout << n << '\n';
		for (int i = 1; i <= n; ++i)
			cout << i << ' ';
		return 0;
	}

	int cnt = n, pos = -1;
	for (int i = 1; i <= k + 1; ++i) {
		int c = n - (i + k);
		if (c % (k + k + 1) == 0 || c % (k + k + 1) >= k + 1) {
			int tmp = c / (k + k + 1) + 1 + (int)(c % (k + k + 1) != 0);
			if (tmp < cnt) {
				cnt = tmp;
				pos = i;
			}
		}
	}
	cout << cnt << '\n';
	for (;pos <= n; pos += (k + k + 1), --cnt) {
		cout << pos << ' ';
	}
	if (cnt)
		cout << pos - k;
	return 0;
}


#include<bits/stdc++.h>
#define debug(x) cout << "[" << #x <<": " << (x) <<"]"<< endl
#define pii pair<int,int>
#define clr(a,b) memset((a),b,sizeof(a))
#define rep(i,a,b) for(int i = a;i < b;i ++)
#define pb push_back
#define MP make_pair
#define LL long long
#define INT(t) int t; scanf("%d",&t)
#define LLI(t) LL t; scanf("%I64d",&t)

using namespace std;

const int maxn = 1100;
int vis[maxn];

int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k)){
        if(k == 0){
            printf("%d\n",n);
            for(int i = 1;i <= n;i ++) printf("%d ",i); printf("\n");
            continue;
        }
        else if(k >= n / 2){
            printf("1\n%d\n",n / 2);
            continue;
        }
        memset(vis,0,sizeof(vis));
        int l = 1,r = n;
        int coun = 1;
        while(r - l + 1 >= 2 * k + 1){
            if(coun == 1){
                for(int i = 1;i <= l + k;i ++)
                    if(i != l) vis[i] = 1;
                l = k + 2;
                for(int i = n;i >= r - k;i --)
                    if(i != r) vis[i] = 1;
                r = n - k - 1;
            }
            else {
                for(int i = l;i <= l + 2 * k + 1;i ++)
                    if(i != l + k) vis[i] = 1;
                l = l + 2 * k + 1;
                if(r - l + 1 < 2 * k + 1) break;
                for(int i = r;i >= r - 2 * k - 1;i --)
                    if(i != r - k) vis[i] = 1;
                r = r - 2 * k - 1;
            }
            ++ coun;
        }

        printf("%d %d\n",l,r);
        for(int i = 1;i <= n;i ++)
            printf("%d ",vis[i]); printf("\n");

        if(l > r){ l = n / 2; r = n / 2 - 1; }

        int a[maxn] ={0}, p = 0;
        int copa[maxn] = {0}, copp = 0;
        for(int i = 1;i < l;i ++)
            if(!vis[i]) a[++ p] = i;
        for(int i = r + 1;i <= n;i ++)
            if(!vis[i]) copa[++ copp] = i;

        printf("%d\n",p + copp);
        int x = r >= l ? (r - l + 1) : 0;

        if(x % 2 == 1){
            for(int i = 1;i <= p;i ++)
                printf("%d ",a[i] + x / 2 + 1);
        }
        else {
            for(int i = 1;i <= p;i ++)
                printf("%d ",a[i] + x / 2);
        }

        for(int i = 1;i <= copp;i ++)
            printf("%d ",copa[i] - x / 2);
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
#define debug(x) cout << "[" << #x <<": " << (x) <<"]"<< endl
#define pii pair<int,int>
#define clr(a,b) memset((a),b,sizeof(a))
#define rep(i,a,b) for(int i = a;i < b;i ++)
#define pb push_back
#define MP make_pair
#define LL long long
#define INT(t) int t; scanf("%d",&t)
#define LLI(t) LL t; scanf("%I64d",&t)

using namespace std;

const int maxn = 1100;
int vis[maxn];

int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k)){
        if(k == 0){
            printf("%d\n",n);
            for(int i = 1;i <= n;i ++) printf("%d ",i); printf("\n");
            continue;
        }
        else if(k >= n / 2){
            printf("1\n%d\n",(n + 1) / 2);
            continue;
        }
        memset(vis,0,sizeof(vis));
        int l = 1,r = n;
        int coun = 1;
        while(r - l + 1 >= 2 * k + 1){
            if(coun == 1){
                for(int i = 1;i <= l + k;i ++)
                    if(i != l) vis[i] = 1;
                l = k + 2;
                for(int i = n;i >= r - k;i --)
                    if(i != r) vis[i] = 1;
                r = n - k - 1;
            }
            else {
                for(int i = l;i <= l + 2 * k + 1;i ++)
                    if(i != l + k) vis[i] = 1;
                l = l + 2 * k + 1;
                if(r - l + 1 < 2 * k + 1) break;
                for(int i = r;i >= r - 2 * k - 1;i --)
                    if(i != r - k) vis[i] = 1;
                r = r - 2 * k - 1;
            }
            ++ coun;
        }

//        printf("%d %d\n",l,r);
//        for(int i = 1;i <= n;i ++)
//            printf("%d ",vis[i]); printf("\n");

        if(l > r){ l = n / 2; r = n / 2 - 1; }

        int a[maxn] ={0}, p = 0;
        int copa[maxn] = {0}, copp = 0;
        for(int i = 1;i < l;i ++)
            if(!vis[i]) a[++ p] = i;
        for(int i = r + 1;i <= n;i ++)
            if(!vis[i]) copa[++ copp] = i;

        printf("%d\n",p + copp);
        int x = r >= l ? (r - l + 1) : 0;

        if(x % 2 == 1){
            for(int i = 1;i <= p;i ++)
                printf("%d ",a[i] + x / 2 + 1);
        }
        else {
            for(int i = 1;i <= p;i ++)
                printf("%d ",a[i] + x / 2);
        }

        for(int i = 1;i <= copp;i ++)
            printf("%d ",copa[i] - x / 2);
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
#define debug(x) cout << "[" << #x <<": " << (x) <<"]"<< endl
#define pii pair<int,int>
#define clr(a,b) memset((a),b,sizeof(a))
#define rep(i,a,b) for(int i = a;i < b;i ++)
#define pb push_back
#define MP make_pair
#define LL long long
#define INT(t) int t; scanf("%d",&t)
#define LLI(t) LL t; scanf("%I64d",&t)

using namespace std;

const int maxn = 1100;
int vis[maxn];

int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k)){
        memset(vis,0,sizeof(vis));
        int l = 1,r = n;
        int coun = 1;
        while(r - l + 1 >= 2 * k + 1){
            if(coun == 1){
                for(int i = 1;i <= l + k;i ++)
                    if(i != l) vis[i] = 1;
                l = k + 2;
                for(int i = n;i >= r - k;i --)
                    if(i != r) vis[i] = 1;
                r = n - k - 1;
            }
            else {
                for(int i = l;i <= l + 2 * k + 1;i ++)
                    if(i != l + k) vis[i] = 1;
                l = l + 2 * k + 2;
                for(int i = r;i >= r - 2 * k - 1;i --)
                    if(i != r - k) vis[i] = 1;
                r = r - 2 * k - 2;
            }
            ++ coun;
        }

//        printf("%d %d\n",l,r);
//        for(int i = 1;i <= n;i ++)
//            printf("%d ",vis[i]); printf("\n");

        if(l > r){ l = n / 2; r = n / 2 - 1; }

        int a[maxn] ={0}, p = 0;
        int copa[maxn] = {0}, copp = 0;
        for(int i = 1;i < l;i ++)
            if(!vis[i]) a[++ p] = i;
        for(int i = r + 1;i <= n;i ++)
            if(!vis[i]) copa[++ copp] = i;

        printf("%d\n",p + copp);
        int x = r >= l ? (r - l + 1) : 0;

        if(x % 2 == 1){
            for(int i = 1;i <= p;i ++)
                printf("%d ",a[i] + x / 2 + 1);
        }
        else {
            for(int i = 1;i <= p;i ++)
                printf("%d ",a[i] + x / 2);
        }

        for(int i = 1;i <= copp;i ++)
            printf("%d ",copa[i] - x / 2);
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
#define debug(x) cout << "[" << #x <<": " << (x) <<"]"<< endl
#define pii pair<int,int>
#define clr(a,b) memset((a),b,sizeof(a))
#define rep(i,a,b) for(int i = a;i < b;i ++)
#define pb push_back
#define MP make_pair
#define LL long long
#define INT(t) int t; scanf("%d",&t)
#define LLI(t) LL t; scanf("%I64d",&t)

using namespace std;

const int maxn = 1100;
int vis[maxn];

int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k)){
        if(k == 0){
            printf("%d\n",n);
            for(int i = 1;i <= n;i ++) printf("%d ",i); printf("\n");
            continue;
        }
        else if(k >= n){
            printf("1\n1\n");
            continue;
        }
        memset(vis,0,sizeof(vis));
        int l = 1,r = n;
        int coun = 1;
        while(r - l + 1 >= 2 * k + 1){
            if(coun == 1){
                for(int i = 1;i <= l + k;i ++)
                    if(i != l) vis[i] = 1;
                l = k + 2;
                for(int i = n;i >= r - k;i --)
                    if(i != r) vis[i] = 1;
                r = n - k - 1;
            }
            else {
                for(int i = l;i <= l + 2 * k + 1;i ++)
                    if(i != l + k) vis[i] = 1;
                l = l + 2 * k + 1;
                if(r - l + 1 < 2 * k + 1) break;
                for(int i = r;i >= r - 2 * k - 1;i --)
                    if(i != r - k) vis[i] = 1;
                r = r - 2 * k - 1;
            }
            ++ coun;
        }

//        printf("%d %d\n",l,r);
//        for(int i = 1;i <= n;i ++)
//            printf("%d ",vis[i]); printf("\n");

        if(l > r){ l = n / 2; r = n / 2 - 1; }

        int a[maxn] ={0}, p = 0;
        int copa[maxn] = {0}, copp = 0;
        for(int i = 1;i < l;i ++)
            if(!vis[i]) a[++ p] = i;
        for(int i = r + 1;i <= n;i ++)
            if(!vis[i]) copa[++ copp] = i;

        printf("%d\n",p + copp);
        int x = r >= l ? (r - l + 1) : 0;

        if(x % 2 == 1){
            for(int i = 1;i <= p;i ++)
                printf("%d ",a[i] + x / 2 + 1);
        }
        else {
            for(int i = 1;i <= p;i ++)
                printf("%d ",a[i] + x / 2);
        }

        for(int i = 1;i <= copp;i ++)
            printf("%d ",copa[i] - x / 2);
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
#define debug(x) cout << "[" << #x <<": " << (x) <<"]"<< endl
#define pii pair<int,int>
#define clr(a,b) memset((a),b,sizeof(a))
#define rep(i,a,b) for(int i = a;i < b;i ++)
#define pb push_back
#define MP make_pair
#define LL long long
#define INT(t) int t; scanf("%d",&t)
#define LLI(t) LL t; scanf("%I64d",&t)

using namespace std;

const int maxn = 1100;
int vis[maxn];

int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k)){
        memset(vis,0,sizeof(vis));
        int l = 1,r = n;
        int coun = 1;
        while(r - l + 1 >= 2 * k + 1){
            if(coun == 1){
                for(int i = 1;i <= l + k;i ++)
                    if(i != l) vis[i] = 1;
                l = k + 2;
                for(int i = n;i >= r - k;i --)
                    if(i != r) vis[i] = 1;
                r = n - k - 1;
            }
            else {
                for(int i = l;i <= l + 2 * k + 1;i ++)
                    if(i != l + k) vis[i] = 1;
                l = l + 2 * k + 2;
                for(int i = r;i >= r - 2 * k - 1;i --)
                    if(i != r - k) vis[i] = 1;
                r = r - 2 * k - 2;
            }
            ++ coun;
        }
        printf("%d %d\n",l,r);
        for(int i = 1;i <= n;i ++)
            printf("%d ",vis[i]); printf("\n");

        if(l > r){ l = n / 2; r = n / 2 - 1; }

        int a[maxn] ={0}, p = 0;
        int copa[maxn] = {0}, copp = 0;
        for(int i = 1;i < l;i ++)
            if(!vis[i]) a[++ p] = i;
        for(int i = r + 1;i <= n;i ++)
            if(!vis[i]) copa[++ copp] = i;

        printf("%d\n",p + copp);
        int x = r >= l ? (r - l + 1) : 0;

        if(x % 2 == 1){
            for(int i = 1;i <= p;i ++)
                printf("%d ",a[i] + x / 2 + 1);
        }
        else {
            for(int i = 1;i <= p;i ++)
                printf("%d ",a[i] + x / 2);
        }

        for(int i = 1;i <= copp;i ++)
            printf("%d ",copa[i] - x / 2);
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
#define debug(x) cout << "[" << #x <<": " << (x) <<"]"<< endl
#define pii pair<int,int>
#define clr(a,b) memset((a),b,sizeof(a))
#define rep(i,a,b) for(int i = a;i < b;i ++)
#define pb push_back
#define MP make_pair
#define LL long long
#define INT(t) int t; scanf("%d",&t)
#define LLI(t) LL t; scanf("%I64d",&t)

using namespace std;

const int maxn = 1100;
int vis[maxn];

int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k)){
        if(k == 0){
            printf("%d\n",n);
            for(int i = 1;i <= n;i ++) printf("%d ",i); printf("\n");
            continue;
        }
        memset(vis,0,sizeof(vis));
        int l = 1,r = n;
        int coun = 1;
        while(r - l + 1 >= 2 * k + 1){
            if(coun == 1){
                for(int i = 1;i <= l + k;i ++)
                    if(i != l) vis[i] = 1;
                l = k + 2;
                for(int i = n;i >= r - k;i --)
                    if(i != r) vis[i] = 1;
                r = n - k - 1;
            }
            else {
                for(int i = l;i <= l + 2 * k + 1;i ++)
                    if(i != l + k) vis[i] = 1;
                l = l + 2 * k + 1;
                if(r - l + 1 < 2 * k + 1) break;
                for(int i = r;i >= r - 2 * k - 1;i --)
                    if(i != r - k) vis[i] = 1;
                r = r - 2 * k - 1;
            }
            ++ coun;
        }

//        printf("%d %d\n",l,r);
//        for(int i = 1;i <= n;i ++)
//            printf("%d ",vis[i]); printf("\n");

        if(l > r){ l = n / 2; r = n / 2 - 1; }

        int a[maxn] ={0}, p = 0;
        int copa[maxn] = {0}, copp = 0;
        for(int i = 1;i < l;i ++)
            if(!vis[i]) a[++ p] = i;
        for(int i = r + 1;i <= n;i ++)
            if(!vis[i]) copa[++ copp] = i;

        printf("%d\n",p + copp);
        int x = r >= l ? (r - l + 1) : 0;

        if(x % 2 == 1){
            for(int i = 1;i <= p;i ++)
                printf("%d ",a[i] + x / 2 + 1);
        }
        else {
            for(int i = 1;i <= p;i ++)
                printf("%d ",a[i] + x / 2);
        }

        for(int i = 1;i <= copp;i ++)
            printf("%d ",copa[i] - x / 2);
        printf("\n");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int  long long int
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define gcd __gcd
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define min3(a,b,c) min(a,min(b,c))
#define mai3(a,b,c) mai(a,mai(b,c))
#define all(i) i.begin(),i.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define set_bit __builtin_popcount //gives number of set_bits
#define ff first
#define ss second
#define cases(t) int t;cin>>t; rep(casn,1,t+1)
#define el cout<<endl;
#define deci(n) int n; scanf("%lld",&n);
#define decs(n) string n; cin>>n;
#define sz(v) v.size()
#define repit(m) for(auto it=m.begin();it!=m.end();it++)
#define ins insert

//  cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";

//SUNEET KUMAR -->  ਸੁਨੀਤ
 int power(int a,int x)
 {
         a%=mod;
        int res=1;
		while(x>0)
        {
            if(x&1)
            res=res*a%mod;
            a=a*a%mod;
            x>>=1;
        }
		return res;
}
int mai(int a,int b)
{
    if(a>b)
    return a;
    else
    {
        return b;
    }
}
int madd(int a,int b)
{
    int ans;
    ans=(a%mod+b%mod)%mod;
    return ans;
}
int mmult(int a,int b)
{
    int ans=1;
    ans=((a%mod)*(b%mod))%mod;
    return ans;
}
int modinverse(int a)
{
    return power(a,mod-2);
}
vector<int>v;
void check(int n)
{
    int count=1;
    while(n>0)
    {
        if(n%2==1)
        {
            v.pb(count);
        }
        count++;
    }
}
int prime[10000009],spf[10000009];
 int dp[10000055];
set<int>temp;
void prmfact(int x)
{
    while(x!=1)
    {
        temp.insert(spf[x]);
        x=x/spf[x];
    }
}
signed main()
{

    for(int i=1;i<=10000004;i++)
    {
        spf[i]=100000055;
    }
    vector<int>v;
    for(int i=2;i*i<=10000007;i++)
    {
        if(prime[i]==0)
        {
            for(int j=i*i;j<=10000007;j+=i)
            {
                prime[j]=1;
                spf[j]=min(i,spf[j]);
            }
        }
    }

    for(int i=2;i<=10000005;i++)
    {
        if(prime[i]==0)
        {
            spf[i]=i;
            v.pb(i);
        }
    }
       deci(n)
       int a[n+4];
       int amx=-100000000;
       for(int i=1;i<=n;i++)
       {
           scanf("%lld",&a[i]);
           amx=max(amx,a[i]);
       }
       map<int,int>m,idx;

        for(int i=1;i<=n;i++)
        {
            temp.clear();
            prmfact(a[i]);
            repit(temp)
            {
                dp[*it]++;
            }
        }
        for(int i=1;i<=10000004;i++)
        {
            dp[i]=dp[i-1]+dp[i];
        }

    //     for(int i=0;i<v.size();i++)
    //     {
    //         m[v[i]]+=0;
    //     }

    //     int count=0;
    //     repit(m)
    //     {
    //         idx[it->ff]=count;
    //         count++;
    //     }

    //     int countr=0;
    //     for(auto it=m.begin();it!=m.end();it++)
    //     {
    //         if(countr==0)
    //         {
    //             dp[0]=it->ss;
    //         }
    //         else
    //         {
    //             dp[countr]=dp[countr-1]+it->ss;
    //         }

    //         countr++;
    //     }
       cases(test)
       {
           deci(x);deci(y);
           y=min(y,amx);
             int ans=dp[y]-dp[x-1];
             printf("%lld\n",ans);
       }
//  cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
}


#include <bits/stdc++.h>
using namespace std;
#define int  long long int
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define gcd __gcd
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define min3(a,b,c) min(a,min(b,c))
#define mai3(a,b,c) mai(a,mai(b,c))
#define all(i) i.begin(),i.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define set_bit __builtin_popcount //gives number of set_bits
#define ff first
#define ss second
#define cases(t) int t;cin>>t; rep(casn,1,t+1)
#define el cout<<endl;
#define deci(n) int n; scanf("%lld",&n);
#define decs(n) string n; cin>>n;
#define sz(v) v.size()
#define repit(m) for(auto it=m.begin();it!=m.end();it++)
#define ins insert

//  cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";

//SUNEET KUMAR -->  ਸੁਨੀਤ
 int power(int a,int x)
 {
         a%=mod;
        int res=1;
		while(x>0)
        {
            if(x&1)
            res=res*a%mod;
            a=a*a%mod;
            x>>=1;
        }
		return res;
}
int mai(int a,int b)
{
    if(a>b)
    return a;
    else
    {
        return b;
    }
}
int madd(int a,int b)
{
    int ans;
    ans=(a%mod+b%mod)%mod;
    return ans;
}
int mmult(int a,int b)
{
    int ans=1;
    ans=((a%mod)*(b%mod))%mod;
    return ans;
}
int modinverse(int a)
{
    return power(a,mod-2);
}
vector<int>v;
void check(int n)
{
    int count=1;
    while(n>0)
    {
        if(n%2==1)
        {
            v.pb(count);
        }
        count++;
    }
}
int prime[10000009],spf[10000009];
 int dp[10000055];
set<int>temp;
void prmfact(int x)
{
    while(x!=1)
    {
        temp.insert(spf[x]);
        x=x/spf[x];
    }
}
signed main()
{

    for(int i=1;i<=10000004;i++)
    {
        spf[i]=100000055;
    }
    vector<int>v;
    for(int i=2;i*i<=10000007;i++)
    {
        if(prime[i]==0)
        {
            for(int j=i*i;j<=10000007;j+=i)
            {
                prime[j]=1;
                spf[j]=min(i,spf[j]);
            }
        }
    }

    for(int i=2;i<=10000005;i++)
    {
        if(prime[i]==0)
        {
            spf[i]=i;
            v.pb(i);
        }
    }
       deci(n)
       int a[n+4];
       int amx=-100000000;
       for(int i=1;i<=n;i++)
       {
           scanf("%lld",&a[i]);
           amx=max(amx,a[i]);
       }
       map<int,int>m,idx;
        for(int i=1;i<=n;i++)
        {
            temp.clear();
            prmfact(a[i]);
            repit(temp)
            {
                m[*it]++;
            }
        }

        for(int i=0;i<v.size();i++)
        {
            m[v[i]]+=0;
        }

        int count=0;
        repit(m)
        {
            idx[it->ff]=count;
            count++;
        }

        int countr=0;
        for(auto it=m.begin();it!=m.end();it++)
        {
            if(countr==0)
            {
                dp[0]=it->ss;
            }
            else
            {
                dp[countr]=dp[countr-1]+it->ss;
            }
            countr++;
        }

       cases(test)
       {
           deci(x);deci(y);
           y=min(y,amx);

                int lod=x,flag=0,bac=y,turn=0;
                for(int k=0;k<11;k++)
                {
                    lod=x+k;
                    if(m.find(lod)!=m.end())
                    {
                        flag=1;
                        break;
                    }
                }

                for(int k=0;k<=11;k++)
                {
                    bac=y-k;
                    if(m.find(bac)!=m.end())
                    {
                        turn=1;
                        break;
                    }
                }
                if(flag==0||turn==0)
                {
                    printf("0\n");
                }
                else
                {

                    map<int,int>::iterator itx=m.find(lod);
                    int index1=idx[itx->ff];
                    int val1,val2;
                    if(index1==0)
                    {
                        val1=0;
                    }
                    else
                    {
                        val1=dp[index1-1];
                    }
                    itx=m.find(bac);
                    int index2=idx[itx->ff];

                    val2=dp[index2];
                    // cout<<val2-val1;el
                    printf("%lld\n",val2-val1);

                }

       }
//  cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
}


#include <bits/stdc++.h>
using namespace std;
#define int  long long int
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define gcd __gcd
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define min3(a,b,c) min(a,min(b,c))
#define mai3(a,b,c) mai(a,mai(b,c))
#define all(i) i.begin(),i.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define set_bit __builtin_popcount //gives number of set_bits
#define ff first
#define ss second
#define cases(t) int t;cin>>t; rep(casn,1,t+1)
#define el cout<<endl;
#define deci(n) int n; scanf("%lld",&n);
#define decs(n) string n; cin>>n;
#define sz(v) v.size()
#define repit(m) for(auto it=m.begin();it!=m.end();it++)
#define ins insert

//  cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";

//SUNEET KUMAR -->  ਸੁਨੀਤ
 int power(int a,int x)
 {
         a%=mod;
        int res=1;
		while(x>0)
        {
            if(x&1)
            res=res*a%mod;
            a=a*a%mod;
            x>>=1;
        }
		return res;
}
int mai(int a,int b)
{
    if(a>b)
    return a;
    else
    {
        return b;
    }
}
int madd(int a,int b)
{
    int ans;
    ans=(a%mod+b%mod)%mod;
    return ans;
}
int mmult(int a,int b)
{
    int ans=1;
    ans=((a%mod)*(b%mod))%mod;
    return ans;
}
int modinverse(int a)
{
    return power(a,mod-2);
}
vector<int>v;
void check(int n)
{
    int count=1;
    while(n>0)
    {
        if(n%2==1)
        {
            v.pb(count);
        }
        count++;
    }
}
int prime[10000009],spf[10000009];
 int dp[10000055];
set<int>temp;
void prmfact(int x)
{
    while(x!=1)
    {
        temp.insert(spf[x]);
        x=x/spf[x];
    }
}
signed main()
{

    for(int i=1;i<=10000004;i++)
    {
        spf[i]=100000055;
    }
    vector<int>v;
    for(int i=2;i*i<=10000007;i++)
    {
        if(prime[i]==0)
        {
            for(int j=i*i;j<=10000007;j+=i)
            {
                prime[j]=1;
                spf[j]=min(i,spf[j]);
            }
        }
    }

    for(int i=2;i<=10000005;i++)
    {
        if(prime[i]==0)
        {
            spf[i]=i;
            v.pb(i);
        }
    }
       deci(n)
       int a[n+4];
       int amx=-100000000;
       for(int i=1;i<=n;i++)
       {
           scanf("%lld",&a[i]);
           amx=max(amx,a[i]);
       }
       map<int,int>m,idx;
        for(int i=1;i<=n;i++)
        {
            temp.clear();
            prmfact(a[i]);
            repit(temp)
            {
                m[*it]++;
            }
        }

        for(int i=0;i<v.size();i++)
        {
            m[v[i]]+=0;
        }

        int count=0;
        repit(m)
        {
            idx[it->ff]=count;
            count++;
        }

        int countr=0;
        for(auto it=m.begin();it!=m.end();it++)
        {
            if(countr==0)
            {
                dp[0]=it->ss;
            }
            else
            {
                dp[countr]=dp[countr-1]+it->ss;
            }
            countr++;
        }

       cases(test)
       {
           deci(x);deci(y);
           y=min(y,amx);

                int lod=x,flag=0,bac=y,turn=0;
                for(int k=0;k<112;k++)
                {
                    lod=x+k;
                    if(m.find(lod)!=m.end())
                    {
                        flag=1;
                        break;
                    }
                }

                for(int k=0;k<=111;k++)
                {
                    bac=y-k;
                    if(m.find(bac)!=m.end())
                    {
                        turn=1;
                        break;
                    }
                }

                    map<int,int>::iterator itx=m.find(lod);
                    int index1=idx[itx->ff];
                    int val1,val2;
                    if(index1==0)
                    {
                        val1=0;
                    }
                    else
                    {
                        val1=dp[index1-1];
                    }
                    itx=m.find(bac);
                    int index2=idx[itx->ff];

                    val2=dp[index2];
                    // cout<<val2-val1;el
                    printf("%lld\n",val2-val1);

       }
//  cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
}


#include <bits/stdc++.h>
using namespace std;
// #define int  long long int
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define gcd __gcd
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define min3(a,b,c) min(a,min(b,c))
#define mai3(a,b,c) mai(a,mai(b,c))
#define all(i) i.begin(),i.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define set_bit __builtin_popcount //gives number of set_bits
#define ff first
#define ss second
#define cases(t) int t;scanf("%d",&t); rep(casn,1,t+1)
#define el cout<<endl;
#define deci(n) int n; scanf("%d",&n);
#define decs(n) string n; cin>>n;
#define sz(v) v.size()
#define repit(m) for(auto it=m.begin();it!=m.end();it++)
#define ins insert

//  cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";

//SUNEET KUMAR -->  ਸੁਨੀਤ
 int power(int a,int x)
 {
         a%=mod;
        int res=1;
		while(x>0)
        {
            if(x&1)
            res=res*a%mod;
            a=a*a%mod;
            x>>=1;
        }
		return res;
}
int mai(int a,int b)
{
    if(a>b)
    return b;
    else
    {
        return a;
    }
}
int madd(int a,int b)
{
    int ans;
    ans=(a%mod+b%mod)%mod;
    return ans;
}
int mmult(int a,int b)
{
    int ans=1;
    ans=((a%mod)*(b%mod))%mod;
    return ans;
}
int modinverse(int a)
{
    return power(a,mod-2);
}
vector<int>v;
void check(int n)
{
    int count=1;
    while(n>0)
    {
        if(n%2==1)
        {
            v.pb(count);
        }
        count++;
    }
}
int prime[10000009],spf[10000009];
 int dp[10000055];
set<int>temp;
void prmfact(int x)
{
    while(x!=1)
    {
        temp.insert(spf[x]);
        x=x/spf[x];
    }
}
signed main()
{

    for(int i=1;i<=10000004;i++)
    {
        spf[i]=100000055;
    }
    for(int i=2;i*i<=10000007;i++)
    {
        if(prime[i]==0)
        {
            for(int j=i*i;j<=10000007;j+=i)
            {
                prime[j]=1;
                spf[j]=min(i,spf[j]);
            }
        }
    }

    for(int i=2;i<=10000005;i++)
    {
        if(prime[i]==0)
        {
            spf[i]=i;
        }
    }
        deci(n)
        int a[n+4];
        int amx=-100000000;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            amx=mai(amx,a[i]);
        }
        map<int,int>m,idx;
        for(int i=1;i<=n;i++)
        {
            temp.clear();
            prmfact(a[i]);
            repit(temp)
            {
                dp[*it]++;
            }
        }

        for(int i=2;i<=10000004;i++)
        {
            dp[i]+=dp[i-1];
        }

       cases(test)
       {
            deci(x);deci(y);
            y=mai(y,10000002);
            if(x>y)
            {
                printf("0\n");
            }
            else
            {
                int ans=dp[y]-dp[x-1];
                printf("%d\n",ans);
            }
       }

//  cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
}


#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <math.h>
#include <map>
#include <iterator>
using namespace std;

typedef int integer;
#define int long
#define make(type, x) type x; cin>>x
#define make2(type, x, y) type x, y; cin>>x>>y
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z
#define make4(type, x, y, z, q) type x, y, z, q; cin>>x>>y>>z>>q
#define ALL(x) (x).begin(), (x).end()
#define FOR(b) for(int i = 0; i <(b); i++)

set<int> seive(int right) {
	vector<char> prime(right + 1, true);
	prime[0] = prime[1] = false;
	for (int i = 2; i <= right; ++i)
		if (prime[i])
			if (i * 1ll * i <= right)
				for (int j = i*i; j <= right; j += i)
					prime[j] = false;
	set<int> a;
	FOR(right + 1) {
		if (prime[i]) a.insert(i);
	}
	return a;
}

void Programme() {
	make(int, n);
	map<int, int> simple_table;
	int max = 0;
	FOR(n) {
		make(int, az);
		if (simple_table.count(az) == 0)
			simple_table.insert(pair<int, int>(az, 1));
		else
			simple_table[az] = (simple_table.find(az)->second)++;
		if (az > max) max = az;
	}
	set<int> simple_num = seive(max);
	for (auto it = --simple_table.end(); it != simple_table.end(); it--) {
		if (simple_num.count(it->first)) continue;
		int someval = it->first;
		for (auto jt = simple_num.begin(); jt != simple_num.lower_bound(it->first); jt++) {
			if (someval%*jt == 0) {
				while (someval%*jt == 0) someval /= *jt;
				if (simple_table.count(*jt) == 0) simple_table.insert(pair<int, int>(*jt, it->second));
				else simple_table[*jt] += it->second;
				if (someval != 1) {
					if (simple_table.count(someval) == 0) simple_table.insert(pair<int, int>(someval, it->second));
					else simple_table[someval] += it->second;
				}
				it = simple_table.erase(it);
				break;
			}
		}
	}
	for (auto it = ++simple_table.begin(); it != simple_table.end(); it++) {
		auto temp = it;
		simple_table[it->first] += (--temp)->second;
	}
	/*int min_simple = simple_table.begin()->first;
	int max_simple = (--simple_table.end())->first;
	int maxv = (--simple_table.end())->second;*/
	simple_table.insert(pair<int, int>(0, 0));
	simple_table.insert(pair<int, int>(1, 0));
	/*auto iter = --simple_table.end();
	int v1 = iter->first;
	int v2 = iter->second;
	simple_table.insert(pair<int, int>(++v1, v2));
	simple_table.insert(pair<int, int>(++v1, v2));*/

	int max_simple = (--simple_table.end())->first;

	make(int, m);
	FOR(m) {
		make2(int, l, r);
		//		if (l <= min_simple) left = 0;
		//		if (r >= max_simple) right = maxv;
		auto right = --simple_table.upper_bound(r);
		if (r > max_simple) right = --simple_table.end();
		auto left = --simple_table.lower_bound(l);
		//if (left == simple_table.end() || left->first >= l) left--;
		cout << ((right->second) - ((left)->second)) << endl;
	}
}

integer main(integer argc, char *argv[]) {
	if (argc > 1) {
		ofstream FileOutput("output.txt");
		ifstream FileInput("input.txt");
		cout.rdbuf(FileOutput.rdbuf());
		cin.rdbuf(FileInput.rdbuf());
		Programme();
		integer CoutStrInFile = 2;
		while (!cin.eof()) {
			char SpaceChar = 'a', PrevC = '`';
			while (!cin.eof()) {
				SpaceChar = cin.get();
				if ((SpaceChar == '\n') && (SpaceChar == PrevC)) break;
				PrevC = SpaceChar;
			}
			if (cin.eof()) return 0;
			FOR(CoutStrInFile + 1) cout << endl;
			Programme();
		}
		FileOutput.close();
		FileInput.close();
	}
	else {
		Programme();
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <math.h>
#include <map>
using namespace std;

typedef int integer;
#define int long long
#define make(type, x) type x; cin>>x
#define make2(type, x, y) type x, y; cin>>x>>y
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z
#define make4(type, x, y, z, q) type x, y, z, q; cin>>x>>y>>z>>q
#define ALL(x) (x).begin(), (x).end()
#define FOR(b) for(int i = 0; i <(b); i++)

set<int> seive() {
	set<int> a;
	for (int i = 2; i <= 10000000; i++) a.insert(i);
	for (auto it = a.begin(); it != a.end(); ) {
		int simple = *it;
		for (auto jt = ++it; jt != a.end();) {
			if (*jt % simple == 0) {
				jt = a.erase(jt);
			}
			else jt++;
		}
	}
	return a;
}

void Programme() {
	make(int, n);
	multiset<int> x;
	map<int, int> simple_table;
	set<int> simple_num = seive();
	FOR(n) {
		make(int, x);
		for (auto it = simple_num.begin(); it != simple_num.end(); it++) {
			if (*it > x) break;
			if (x % *it == 0) {
				if (simple_table.count(*it) == 0) {
					simple_table.insert(pair<int, int>(*it, 1));
				}
				else {
					simple_table[*it] = (simple_table.find(*it)->second)++;
				}
			}
		}
	}
	make(int, m);
	FOR(m) {
		make2(int, l, r);
		int answer = 0;
		for (auto it = simple_table.lower_bound(l); it != simple_table.upper_bound(r); it++) {
			answer += it->second;
		}
		cout << answer << endl;
	}
}

integer main(integer argc, char *argv[]) {
	if (argc > 1) {
		ofstream FileOutput("output.txt");
		ifstream FileInput("input.txt");
		cout.rdbuf(FileOutput.rdbuf());
		cin.rdbuf(FileInput.rdbuf());
		Programme();
		integer CoutStrInFile = 2;
		while (!cin.eof()) {
			char SpaceChar = 'a', PrevC = '`';
			while (!cin.eof()) {
				SpaceChar = cin.get();
				if ((SpaceChar == '\n') && (SpaceChar == PrevC)) break;
				PrevC = SpaceChar;
			}
			if (cin.eof()) return 0;
			FOR(CoutStrInFile + 1) cout << endl;
			Programme();
		}
		FileOutput.close();
		FileInput.close();
	}
	else {
		Programme();
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <math.h>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
using namespace std;

typedef int integer;
#define int long long
#define make(type, x) type x; cin>>x
#define make2(type, x, y) type x, y; cin>>x>>y
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z
#define make4(type, x, y, z, q) type x, y, z, q; cin>>x>>y>>z>>q
#define ALL(x) (x).begin(), (x).end()
#define FOR(b) for(int i = 0; i <(b); i++)

void Programme() {
	const int limit = 1e7+2;
	vector<int> arr(limit);
	make(int, n);
	FOR(n) {
		make(int, a);
		arr[a]++;
	};

	vector<int> simpl(limit, true);
	simpl[0] = simpl[1] = false;
	for (int i = 2; i < simpl.size(); ++i)
		if (simpl[i])
			if (i*i < simpl.size())
				for (int j = i*i; j < simpl.size(); j += i)
					simpl[j] = false;
	for (int i = 2; i < simpl.size(); ++i)
		if (simpl[i]) {
			simpl[i] = 0;
			for (int j = i; j < simpl.size(); j += i)
				simpl[i] += arr[j];
		}
	for (int i = 0; i < simpl.size()-1; i++)
		simpl[i + 1] += simpl[i];
	make(int, m);
	FOR(m) {
		make2(int, l, r);
		if (r >= limit) r = 1e7;
		cout << simpl[r] - simpl[l-1] << endl;
	}
}

integer main(integer argc, char *argv[]) {
	ios_base::sync_with_stdio(0);
	if (argc > 1) {
		ofstream FileOutput("output.txt");
		ifstream FileInput("input.txt");
		cout.rdbuf(FileOutput.rdbuf());
		cin.rdbuf(FileInput.rdbuf());
		Programme();
		integer CoutStrInFile = 2;
		while (!cin.eof()) {
			char SpaceChar = 'a', PrevC = '`';
			while (!cin.eof()) {
				SpaceChar = cin.get();
				if ((SpaceChar == '\n') && (SpaceChar == PrevC)) break;
				PrevC = SpaceChar;
			}
			if (cin.eof()) return 0;
			FOR(CoutStrInFile + 1) cout << endl;
			Programme();
		}
		FileOutput.close();
		FileInput.close();
	}
	else {
		Programme();
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <math.h>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
using namespace std;

typedef int integer;
#define int long long
#define make(type, x) type x; cin>>x
#define make2(type, x, y) type x, y; cin>>x>>y
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z
#define make4(type, x, y, z, q) type x, y, z, q; cin>>x>>y>>z>>q
#define ALL(x) (x).begin(), (x).end()
#define FOR(b) for(int i = 0; i <(b); i++)

void Programme() {
	const int limit = 1e5 + 2;
	vector<int> arr(limit);
	make(int, n);
	FOR(n) {
		make(int, a);
		arr[a]++;
	};

	vector<int> simpl(limit, true);
	simpl[0] = simpl[1] = false;
	for (int i = 2; i < simpl.size(); ++i)
		if (simpl[i])
			if (i*i < simpl.size())
				for (int j = i*i; j < simpl.size(); j += i)
					simpl[j] = false;
	for (int i = 2; i < simpl.size(); ++i)
		if (simpl[i]) {
			simpl[i] = 0;
			for (int j = i; j < simpl.size(); j += i)
				simpl[i] += arr[j];
		}
	for (int i = 0; i < simpl.size() - 1; i++)
		simpl[i + 1] += simpl[i];
	make(int, m);
	FOR(m) {
		make2(int, l, r);
		if (r >= limit) r = 1e5;
		if (l >= limit) cout << 0 << endl;
		else cout << simpl[r] - simpl[l - 1] << endl;
	}
}

integer main(integer argc, char *argv[]) {
	ios_base::sync_with_stdio(0);
	if (argc > 1) {
		ofstream FileOutput("output.txt");
		ifstream FileInput("input.txt");
		cout.rdbuf(FileOutput.rdbuf());
		cin.rdbuf(FileInput.rdbuf());
		Programme();
		integer CoutStrInFile = 2;
		while (!cin.eof()) {
			char SpaceChar = 'a', PrevC = '`';
			while (!cin.eof()) {
				SpaceChar = cin.get();
				if ((SpaceChar == '\n') && (SpaceChar == PrevC)) break;
				PrevC = SpaceChar;
			}
			if (cin.eof()) return 0;
			FOR(CoutStrInFile + 1) cout << endl;
			Programme();
		}
		FileOutput.close();
		FileInput.close();
	}
	else {
		Programme();
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <math.h>
using namespace std;

typedef int integer;
#define int long long
#define make(type, x) type x; cin>>x
#define make2(type, x, y) type x, y; cin>>x>>y
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z
#define make4(type, x, y, z, q) type x, y, z, q; cin>>x>>y>>z>>q
#define ALL(x) (x).begin(), (x).end()
#define FOR(b) for(int i = 0; i <(b); i++)

set<int> seive(int left, int right) {
	set<int> a;
	for (int i = 2; i <= right; i++) a.insert(i);
	for (auto it = a.begin(); it != a.end(); ) {
		int simple = *it;
		for (auto jt = ++it; jt != a.end();) {
			if (*jt % simple == 0) {
				jt = a.erase(jt);
			}
			else jt++;
		}
	}
	for (auto it = a.begin(); it != a.end();) {
		if (*it < left) it = a.erase(it);
		else break;
	}
	return a;
}

void Programme() {
	make(int, n);
	multiset<int> x;
	FOR(n) {
		int z;
		cin >> z;
		x.insert(z);
	}
	make(int, m);
	FOR(m) {
		make2(int, l, r);
		set<int> a = seive(l, r);
		int answer = 0;
		for (auto it = a.begin(); it != a.end(); it++) {
			for (auto jt = x.begin(); jt != x.end(); jt++) {
				if (*jt%*it == 0) answer++;
			}
		}
		cout << answer << endl;
	}
}

integer main(integer argc, char *argv[]) {
	if (argc > 1) {
		ofstream FileOutput("output.txt");
		ifstream FileInput("input.txt");
		cout.rdbuf(FileOutput.rdbuf());
		cin.rdbuf(FileInput.rdbuf());
		Programme();
		integer CoutStrInFile = 2;
		while (!cin.eof()) {
			char SpaceChar = 'a', PrevC = '`';
			while (!cin.eof()) {
				SpaceChar = cin.get();
				if ((SpaceChar == '\n') && (SpaceChar == PrevC)) break;
				PrevC = SpaceChar;
			}
			if (cin.eof()) return 0;
			FOR(CoutStrInFile + 1) cout << endl;
			Programme();
		}
		FileOutput.close();
		FileInput.close();
	}
	else {
		Programme();
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <math.h>
#include <map>
#include <iterator>
using namespace std;

typedef int integer;
#define int long
#define make(type, x) type x; cin>>x
#define make2(type, x, y) type x, y; cin>>x>>y
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z
#define make4(type, x, y, z, q) type x, y, z, q; cin>>x>>y>>z>>q
#define ALL(x) (x).begin(), (x).end()
#define FOR(b) for(int i = 0; i <(b); i++)

set<int> seive(int right) {
	vector<char> prime(right + 1, true);
	prime[0] = prime[1] = false;
	for (int i = 2; i <= right; ++i)
		if (prime[i])
			if (i * 1ll * i <= right)
				for (int j = i*i; j <= right; j += i)
					prime[j] = false;
	set<int> a;
	FOR(right + 1) {
		if (prime[i]) a.insert(i);
	}
	return a;
}

void Programme() {
	make(int, n);
	set<int> simple_num;
	map<int, pair<int, set<int>::iterator>> simple_table;
	int max = 0;
	FOR(n) {
		make(int, az);
		simple_table[az] = pair<int, set<int>::iterator> (simple_table[az].first + 1, simple_table[az].second);
		if (az > max) max = az;
	}
	simple_num = seive(max);
	for (auto it = simple_table.begin(); it != simple_table.end(); it++) {
		simple_table[it->first] = pair<int, set<int>::iterator>(it->second.first, simple_num.begin());
	}
	for (auto it = --simple_table.end(); it != simple_table.end(); it--) {
		if (simple_num.count(it->first)) continue;
		int someval = it->first;
		for (set<int>::iterator jt = it->second.second; jt != simple_num.lower_bound((it->first)/2 + 1); jt++) {
			if (someval%*jt == 0) {
				while (someval%*jt == 0) someval /= *jt;
				auto temp = jt;
				temp++;
				simple_table[*jt] = pair<int, set<int>::iterator> (simple_table[*jt].first + it->second.first, temp);
				if (someval != 1) {
					simple_table[someval] = pair<int, set<int>::iterator>(simple_table[someval].first + it->second.first, temp);
				}
				it = simple_table.erase(it);
				break;
			}
		}
	}
	for (auto it = ++simple_table.begin(); it != simple_table.end(); it++) {
		auto temp = it;
		simple_table[it->first] = pair<int, set<int>::iterator>(simple_table[it->first].first + (--temp)->second.first, temp->second.second);
	}
	simple_table.insert(pair<int, pair<int, set<int>::iterator>>(0, pair<int, set<int>::iterator>(0, simple_num.begin())));
	simple_table.insert(pair<int, pair<int, set<int>::iterator>>(1, pair<int, set<int>::iterator>(0, simple_num.begin())));

	int max_simple = (--simple_table.end())->first;

	make(int, m);
	FOR(m) {
		make2(int, l, r);
		auto right = --simple_table.upper_bound(r);
		if (r > max_simple) right = --simple_table.end();
		auto left = --simple_table.lower_bound(l);
		cout << ((right->second.first) - ((left)->second.first)) << endl;
	}
}

integer main(integer argc, char *argv[]) {
	if (argc > 1) {
		ofstream FileOutput("output.txt");
		ifstream FileInput("input.txt");
		cout.rdbuf(FileOutput.rdbuf());
		cin.rdbuf(FileInput.rdbuf());
		Programme();
		integer CoutStrInFile = 2;
		while (!cin.eof()) {
			char SpaceChar = 'a', PrevC = '`';
			while (!cin.eof()) {
				SpaceChar = cin.get();
				if ((SpaceChar == '\n') && (SpaceChar == PrevC)) break;
				PrevC = SpaceChar;
			}
			if (cin.eof()) return 0;
			FOR(CoutStrInFile + 1) cout << endl;
			Programme();
		}
		FileOutput.close();
		FileInput.close();
	}
	else {
		Programme();
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <math.h>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
using namespace std;

typedef int integer;
#define int long long
#define make(type, x) type x; cin>>x
#define make2(type, x, y) type x, y; cin>>x>>y
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z
#define make4(type, x, y, z, q) type x, y, z, q; cin>>x>>y>>z>>q
#define ALL(x) (x).begin(), (x).end()
#define FOR(b) for(int i = 0; i <(b); i++)

void Programme() {
	const int limit = 10000001;
	vector<int> arr(limit);
	make(int, n);
	FOR(n) {
		make(int, a);
		arr[a]++;
	};

	vector<int> simpl(limit, true);
	simpl[0] = simpl[1] = false;
	for (int i = 2; i < simpl.size(); ++i)
		if (simpl[i])
			if (i*i < simpl.size())
				for (int j = i*i; j < simpl.size(); j += i)
					simpl[j] = false;
	for (int i = 2; i < simpl.size(); ++i)
		if (simpl[i]) {
			simpl[i] = 0;
			for (int j = i; j < simpl.size(); j += i)
				simpl[i] += arr[j];
		}
	for (int i = 0; i < simpl.size()-1; i++)
		simpl[i + 1] += simpl[i];
	make(int, m);
	FOR(m) {
		make2(int, l, r);
		if (r > limit) r = limit - 1;
		cout << simpl[r] - simpl[l-1] << endl;
	}
}

integer main(integer argc, char *argv[]) {
	if (argc > 1) {
		ofstream FileOutput("output.txt");
		ifstream FileInput("input.txt");
		cout.rdbuf(FileOutput.rdbuf());
		cin.rdbuf(FileInput.rdbuf());
		Programme();
		integer CoutStrInFile = 2;
		while (!cin.eof()) {
			char SpaceChar = 'a', PrevC = '`';
			while (!cin.eof()) {
				SpaceChar = cin.get();
				if ((SpaceChar == '\n') && (SpaceChar == PrevC)) break;
				PrevC = SpaceChar;
			}
			if (cin.eof()) return 0;
			FOR(CoutStrInFile + 1) cout << endl;
			Programme();
		}
		FileOutput.close();
		FileInput.close();
	}
	else {
		Programme();
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <math.h>
#include <map>
using namespace std;

typedef int integer;
#define int long long
#define make(type, x) type x; cin>>x
#define make2(type, x, y) type x, y; cin>>x>>y
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z
#define make4(type, x, y, z, q) type x, y, z, q; cin>>x>>y>>z>>q
#define ALL(x) (x).begin(), (x).end()
#define FOR(b) for(int i = 0; i <(b); i++)

set<int> seive(int right) {
	set<int> a;
	for (int i = 2; i <= right; i++) a.insert(i);
	for (auto it = a.begin(); it != a.end(); ) {
		int simple = *it;
		for (auto jt = ++it; jt != a.end();) {
			if (*jt % simple == 0) {
				jt = a.erase(jt);
			}
			else jt++;
		}
	}
	return a;
}

void Programme() {
	make(int, n);
	multiset<int> x;
	map<int, int> simple_table;
	vector<int> a(n);
	int max = 0;
	FOR(n) {
		cin >> a[i];
		if (a[i] > max) max = a[i];
	}
	set<int> simple_num = seive(max);
	FOR(n) {
		int x = a[i];
		for (auto it = simple_num.begin(); it != simple_num.end(); it++) {
			if (*it > x) break;
			if (x % *it == 0) {
				if (simple_table.count(*it) == 0) {
					simple_table.insert(pair<int, int>(*it, 1));
				}
				else {
					simple_table[*it] = (simple_table.find(*it)->second)++;
				}
			}
		}
	}
	make(int, m);
	FOR(m) {
		make2(int, l, r);
		int answer = 0;
		for (auto it = simple_table.lower_bound(l); it != simple_table.upper_bound(r); it++) {
			answer += it->second;
		}
		cout << answer << endl;
	}
}

integer main(integer argc, char *argv[]) {
	if (argc > 1) {
		ofstream FileOutput("output.txt");
		ifstream FileInput("input.txt");
		cout.rdbuf(FileOutput.rdbuf());
		cin.rdbuf(FileInput.rdbuf());
		Programme();
		integer CoutStrInFile = 2;
		while (!cin.eof()) {
			char SpaceChar = 'a', PrevC = '`';
			while (!cin.eof()) {
				SpaceChar = cin.get();
				if ((SpaceChar == '\n') && (SpaceChar == PrevC)) break;
				PrevC = SpaceChar;
			}
			if (cin.eof()) return 0;
			FOR(CoutStrInFile + 1) cout << endl;
			Programme();
		}
		FileOutput.close();
		FileInput.close();
	}
	else {
		Programme();
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <math.h>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
using namespace std;

typedef int integer;
#define int long long
#define make(type, x) type x; cin>>x
#define make2(type, x, y) type x, y; cin>>x>>y
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z
#define make4(type, x, y, z, q) type x, y, z, q; cin>>x>>y>>z>>q
#define ALL(x) (x).begin(), (x).end()
#define FOR(b) for(int i = 0; i <(b); i++)

void Programme() {
	const int limit = 1e5 + 2;
	vector<int> arr(limit);
	make(int, n);
	FOR(n) {
		make(int, a);
		arr[a]++;
	};

	vector<int> simpl(limit, true);
	simpl[0] = simpl[1] = false;
	for (int i = 2; i < simpl.size(); ++i)
		if (simpl[i])
			if (i*i < simpl.size())
				for (int j = i*i; j < simpl.size(); j += i)
					simpl[j] = false;
	for (int i = 2; i < simpl.size(); ++i)
		if (simpl[i]) {
			simpl[i] = 0;
			for (int j = i; j < simpl.size(); j += i)
				simpl[i] += arr[j];
		}
	for (int i = 0; i < simpl.size() - 1; i++)
		simpl[i + 1] += simpl[i];
	make(int, m);
	FOR(m) {
		make2(int, l, r);
		if (r >= limit) r = 1e5;
		if (l >= limit) cout << 0;
		else cout << simpl[r] - simpl[l - 1] << endl;
	}
}

integer main(integer argc, char *argv[]) {
	ios_base::sync_with_stdio(0);
	if (argc > 1) {
		ofstream FileOutput("output.txt");
		ifstream FileInput("input.txt");
		cout.rdbuf(FileOutput.rdbuf());
		cin.rdbuf(FileInput.rdbuf());
		Programme();
		integer CoutStrInFile = 2;
		while (!cin.eof()) {
			char SpaceChar = 'a', PrevC = '`';
			while (!cin.eof()) {
				SpaceChar = cin.get();
				if ((SpaceChar == '\n') && (SpaceChar == PrevC)) break;
				PrevC = SpaceChar;
			}
			if (cin.eof()) return 0;
			FOR(CoutStrInFile + 1) cout << endl;
			Programme();
		}
		FileOutput.close();
		FileInput.close();
	}
	else {
		Programme();
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <math.h>
#include <map>
#include <iterator>
using namespace std;

typedef int integer;
#define int long long
#define make(type, x) type x; cin>>x
#define make2(type, x, y) type x, y; cin>>x>>y
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z
#define make4(type, x, y, z, q) type x, y, z, q; cin>>x>>y>>z>>q
#define ALL(x) (x).begin(), (x).end()
#define FOR(b) for(int i = 0; i <(b); i++)

set<int> seive(int right) {
	vector<char> prime(right + 1, true);
	prime[0] = prime[1] = false;
	for (int i = 2; i <= right; ++i)
		if (prime[i])
			if (i * 1ll * i <= right)
				for (int j = i*i; j <= right; j += i)
					prime[j] = false;
	set<int> a;
	FOR(right + 1) {
		if (prime[i]) a.insert(i);
	}
	return a;
}

void Programme() {
	make(int, n);
	map<int, int> simple_table;
	int max = 0;
	FOR(n) {
		make(int, az);
		if (simple_table.count(az) == 0)
			simple_table.insert(pair<int, int>(az, 1));
		else
			simple_table[az] = (simple_table.find(az)->second)++;
		if (az > max) max = az;
	}
	set<int> simple_num = seive(max);
	for (auto it = --simple_table.end(); it != simple_table.end();) {
		if (simple_num.count(it->first)) {
			it--;
			continue;
		}
		auto temp = it;
		temp--;
		for (auto jt = simple_num.begin(); jt != simple_num.lower_bound(it->first); jt++) {
			int someval = it->first;
			if (someval%*jt == 0) {
				while (someval%*jt == 0) someval /= *jt;
				if (simple_table.count(*jt) == 0) simple_table.insert(pair<int, int>(*jt, it->second));
				else simple_table[*jt] += it->second;
				if (someval != 1) {
					if (simple_table.count(someval) == 0) simple_table.insert(pair<int, int>(someval, it->second));
					else simple_table[someval] += it->second;
				}
				simple_table.erase(it);
				if (someval != 1) it = simple_table.find(someval);
				else break;
			}
		}
		it = temp;
	}
	for (auto it = ++simple_table.begin(); it != simple_table.end(); it++) {
		auto temp = it;
		simple_table[it->first] += (--temp)->second;
	}
	simple_table.insert(pair<int, int>(0, 0));
	simple_table.insert(pair<int, int>(1, 0));
	int max_simple = (--simple_table.end())->first;

	make(int, m);
	FOR(m) {
		make2(int, l, r);
		auto right = --simple_table.upper_bound(r);
		if (r > max_simple) right = --simple_table.end();
		auto left = --simple_table.lower_bound(l);
		cout << ((right->second) - ((left)->second)) << endl;
	}
}

integer main(integer argc, char *argv[]) {
	if (argc > 1) {
		ofstream FileOutput("output.txt");
		ifstream FileInput("input.txt");
		cout.rdbuf(FileOutput.rdbuf());
		cin.rdbuf(FileInput.rdbuf());
		Programme();
		integer CoutStrInFile = 2;
		while (!cin.eof()) {
			char SpaceChar = 'a', PrevC = '`';
			while (!cin.eof()) {
				SpaceChar = cin.get();
				if ((SpaceChar == '\n') && (SpaceChar == PrevC)) break;
				PrevC = SpaceChar;
			}
			if (cin.eof()) return 0;
			FOR(CoutStrInFile + 1) cout << endl;
			Programme();
		}
		FileOutput.close();
		FileInput.close();
	}
	else {
		Programme();
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <math.h>
#include <map>
using namespace std;

typedef int integer;
#define int long long
#define make(type, x) type x; cin>>x
#define make2(type, x, y) type x, y; cin>>x>>y
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z
#define make4(type, x, y, z, q) type x, y, z, q; cin>>x>>y>>z>>q
#define ALL(x) (x).begin(), (x).end()
#define FOR(b) for(int i = 0; i <(b); i++)

set<int> seive(int right) {
	vector<char> prime(right + 1, true);
	prime[0] = prime[1] = false;
	for (int i = 2; i <= right; ++i)
		if (prime[i])
			if (i * 1ll * i <= right)
				for (int j = i*i; j <= right; j += i)
					prime[j] = false;
	set<int> a;
	FOR(right + 1) {
		if (prime[i]) a.insert(i);
	}
	return a;
}

void Programme() {
	make(int, n);
	multiset<int> x;
	map<int, int> simple_table;
	vector<int> a(n);
	int max = 0;
	FOR(n) {
		cin >> a[i];
		if (a[i] > max) max = a[i];
	}
	set<int> simple_num = seive(max);
	FOR(n) {
		int x = a[i];
		for (auto it = simple_num.begin(); it != simple_num.end(); it++) {
			if (*it > x) break;
			if (x % *it == 0) {
				if (simple_table.count(*it) == 0) {
					simple_table.insert(pair<int, int>(*it, 1));
				}
				else {
					simple_table[*it] = (simple_table.find(*it)->second)++;
				}
			}
		}
	}
	make(int, m);
	FOR(m) {
		make2(int, l, r);
		int answer = 0;
		for (auto it = simple_table.lower_bound(l); it != simple_table.upper_bound(r); it++) {
			answer += it->second;
		}
		cout << answer << endl;
	}
}

integer main(integer argc, char *argv[]) {
	if (argc > 1) {
		ofstream FileOutput("output.txt");
		ifstream FileInput("input.txt");
		cout.rdbuf(FileOutput.rdbuf());
		cin.rdbuf(FileInput.rdbuf());
		Programme();
		integer CoutStrInFile = 2;
		while (!cin.eof()) {
			char SpaceChar = 'a', PrevC = '`';
			while (!cin.eof()) {
				SpaceChar = cin.get();
				if ((SpaceChar == '\n') && (SpaceChar == PrevC)) break;
				PrevC = SpaceChar;
			}
			if (cin.eof()) return 0;
			FOR(CoutStrInFile + 1) cout << endl;
			Programme();
		}
		FileOutput.close();
		FileInput.close();
	}
	else {
		Programme();
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <math.h>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
using namespace std;

typedef int integer;
#define int long long
#define make(type, x) type x; cin>>x
#define make2(type, x, y) type x, y; cin>>x>>y
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z
#define make4(type, x, y, z, q) type x, y, z, q; cin>>x>>y>>z>>q
#define ALL(x) (x).begin(), (x).end()
#define FOR(b) for(int i = 0; i <(b); i++)

void Programme() {
	const int limit = 1e7 + 2;
	vector<int> arr(limit);
	make(int, n);
	FOR(n) {
		make(int, a);
		arr[a]++;
	};

	vector<int> simpl(limit, true);
	simpl[0] = simpl[1] = false;
	for (int i = 2; i < simpl.size(); ++i)
		if (simpl[i])
			if (i*i < simpl.size())
				for (int j = i*i; j < simpl.size(); j += i)
					simpl[j] = false;
	for (int i = 2; i < simpl.size(); ++i)
		if (simpl[i]) {
			simpl[i] = 0;
			for (int j = i; j < simpl.size(); j += i)
				simpl[i] += arr[j];
		}
	for (int i = 0; i < simpl.size() - 1; i++)
		simpl[i + 1] += simpl[i];
	make(int, m);
	FOR(m) {
		make2(int, l, r);
		if (r >= limit) r = 1e7;
		if (l >= limit) cout << 0 << endl;
		else cout << simpl[r] - simpl[l - 1] << endl;
	}
}

integer main(integer argc, char *argv[]) {
	ios_base::sync_with_stdio(0);
	if (argc > 1) {
		ofstream FileOutput("output.txt");
		ifstream FileInput("input.txt");
		cout.rdbuf(FileOutput.rdbuf());
		cin.rdbuf(FileInput.rdbuf());
		Programme();
		integer CoutStrInFile = 2;
		while (!cin.eof()) {
			char SpaceChar = 'a', PrevC = '`';
			while (!cin.eof()) {
				SpaceChar = cin.get();
				if ((SpaceChar == '\n') && (SpaceChar == PrevC)) break;
				PrevC = SpaceChar;
			}
			if (cin.eof()) return 0;
			FOR(CoutStrInFile + 1) cout << endl;
			Programme();
		}
		FileOutput.close();
		FileInput.close();
	}
	else {
		Programme();
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
#define ff first
#define ss second
ll n,m,l,r,x;
ll cnt[10000005],prime[10000005],num[10000005];

void primal()
{
    for(ll i=0;i<=1e7;i++)
        prime[i]=i;
    for(ll i=2;i<=1e7;i++)
    {
        if(prime[i]==i)
        {
            for(ll j=i;j<=1e7;j+=i)
            {
                prime[j]=i;
                num[i]+=cnt[j];
            }
        }
    }
}

int main()
{
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>x;
        cnt[x]++;
    }
    primal();
    for(ll i=2;i<=1e7;i++)
        num[i]+=num[i-1];
    // cout<<num[2]<<" "<<num[3]<<" "<<num[5]<<" "<<num[7]<<" "<<num[11]<<endl;
    cin>>m;
    while(m--)
    {
        cin>>l>>r;
        if (l>=1e7)l=1e7-1;
		if (r>=1e7)r=1e7-1;
        cout<<num[r]-num[l-1]<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
#define ff first
#define ss second
ll n,m,l,r,x;
ll cnt[10000005],prime[10000005],num[10000005];

void primal()
{
    for(ll i=0;i<=1e7;i++)
        prime[i]=i;
    for(ll i=2;i<=1e7;i++)
    {
        if(prime[i]==i)
        {
            for(ll j=i;j<=1e7;j+=i)
            {
                prime[j]=i;
                num[i]+=cnt[j];
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>x;
        cnt[x]++;
    }
    primal();
    for(ll i=2;i<=1e7;i++)
        num[i]+=num[i-1];
    // cout<<num[2]<<" "<<num[3]<<" "<<num[5]<<" "<<num[7]<<" "<<num[11]<<endl;
    cin>>m;
    while(m--)
    {
        cin>>l>>r;
        if (l>=1e7)l=1e7-1;
		if (r>=1e7)r=1e7-1;
        cout<<num[r]-num[l-1]<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
#define ff first
#define ss second
ll n,m,l,r;
ll arr[1000005],cnt[10000005];
ll prime[10000005];

void primal()
{
    prime[0]=0;prime[1]=1;
    for(ll i=2;i<=1e7;i++)
        prime[i]=i;
    for(ll i=2;i*i<=1e7;i++)
    {
        if(prime[i]==i)
        {
            for(ll j=i*i;j<=1e7;j+=i)
                prime[j]=i;
        }
    }
}

void check(ll x)
{
    while(x>1)
    {
        ll temp=prime[x];
        cnt[temp]++;
        while(x%temp==0)
        {
            x/=temp;
        }
    }
}

int main()
{
    primal();
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
        // cnt[arr[i]]++;
        check(arr[i]);
    }
    for(ll i=1;i<=1e7;i++)
        cnt[i]+=cnt[i-1];
    // cout<<cnt[2]<<" "<<cnt[3]<<" "<<cnt[5]<<" "<<cnt[7]<<" "<<cnt[11]<<endl;
    cin>>m;
    while(m--)
    {
        cin>>l>>r;
        if(l>=1e7) l=1e7-1;
        if(r>=1e7) r=1e7-1;
        // cout<<"l "<<cnt[l]<<endl;
        // cout<<"r "<<cnt[r]<<endl;
        cout<<cnt[r]-cnt[l-1]<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
#define ff first
#define ss second
ll n,m,l,r,x;
ll cnt[10000005],prime[10000005];

void primal()
{
    prime[0]=0;prime[1]=1;
    for(ll i=2;i<=1e7;i++)
        prime[i]=i;
    for(ll i=2;i*i<=1e7;i++)
    {
        if(prime[i]==i)
        {
            for(ll j=i*i;j<=1e7;j+=i)
                prime[j]=i;
        }
    }
}

void check(ll x)
{
    while(x>1)
    {
        ll temp=prime[x];
        cnt[temp]++;
        while(x%temp==0)
        {
            x/=temp;
        }
    }
}

int main()
{
    primal();
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>x;
        check(x);
    }
    for(ll i=1;i<=1e7;i++)
        cnt[i]+=cnt[i-1];
    cin>>m;
    while(m--)
    {
        cin>>l>>r;
        cout<<cnt[r]-cnt[l-1]<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
#define ff first
#define ss second
ll n,m,l,r;
ll arr[1000005],cnt[10000005];
ll prime[10000005];
ll num[10000005];

void primal()
{
    prime[0]=0;prime[1]=1;
    for(ll i=2;i<=1e7;i++)
        prime[i]=i;
    for(ll i=2;i*i<=1e7;i++)
    {
        if(prime[i]==i)
        {
            for(ll j=i*i;j<=1e7;j+=i)
                prime[j]=i;
        }
    }
}

void check(ll x)
{
    while(x>1)
    {
        ll temp=prime[x];
        cnt[temp]++;
        while(x%temp==0)
        {
            x/=temp;
        }
    }
}

int main()
{
    primal();
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
        // cnt[arr[i]]++;
        check(arr[i]);
    }
    for(ll i=1;i<=1e7;i++)
        cnt[i]+=cnt[i-1];
    // cout<<cnt[2]<<" "<<cnt[3]<<" "<<cnt[5]<<" "<<cnt[7]<<" "<<cnt[11]<<endl;
    cin>>m;
    while(m--)
    {
        cin>>l>>r;
        // cout<<"l "<<cnt[l]<<endl;
        // cout<<"r "<<cnt[r]<<endl;
        cout<<cnt[r]-cnt[l-1]<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
#define ff first
#define ss second
ll n,m,l,r;
ll arr[1000005],cnt[10000005];
ll prime[10000005];

void primal()
{
    prime[0]=0;prime[1]=1;
    for(ll i=2;i<=1e7;i++)
        prime[i]=i;
    for(ll i=2;i*i<=1e7;i++)
    {
        if(prime[i]==i)
        {
            for(ll j=i*i;j<=1e7;j+=i)
                prime[j]=i;
        }
    }
}

void check(ll x)
{
    while(x>1)
    {
        ll temp=prime[x];
        cnt[temp]++;
        while(x%temp==0)
        {
            x/=temp;
        }
    }
}

int main()
{
    primal();
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
        // cnt[arr[i]]++;
        check(arr[i]);
    }
    for(ll i=1;i<=1e7;i++)
        cnt[i]+=cnt[i-1];
    // cout<<cnt[2]<<" "<<cnt[3]<<" "<<cnt[5]<<" "<<cnt[7]<<" "<<cnt[11]<<endl;
    cin>>m;
    while(m--)
    {
        cin>>l>>r;
        // cout<<"l "<<cnt[l]<<endl;
        // cout<<"r "<<cnt[r]<<endl;
        cout<<cnt[r]-cnt[l-1]<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
#define ff first
#define ss second
ll n,m,l,r,x;
ll cnt[10000005],prime[10000005],num[10000005];

void primal()
{
    for(ll i=0;i<=1e7;i++)
        prime[i]=i;
    for(ll i=2;i<=1e7;i++)
    {
        if(prime[i]==i)
        {
            for(ll j=i;j<=1e7;j+=i)
            {
                prime[j]=i;
                num[i]+=cnt[j];
            }
        }
    }
}

int main()
{
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>x;
        cnt[x]++;
    }
    primal();
    for(ll i=2;i<=1e7;i++)
        num[i]+=num[i-1];
    // cout<<num[2]<<" "<<num[3]<<" "<<num[5]<<" "<<num[7]<<" "<<num[11]<<endl;
    cin>>m;
    while(m--)
    {
        cin>>l>>r;
        cout<<num[r]-num[l-1]<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
#define ff first
#define ss second
ll n,m,l,r,x;
ll cnt[10000005],prime[10000005],num[10000005];

void primal()
{
    for(ll i=0;i<=1e7;i++)
        prime[i]=i;
    for(ll i=2;i*i<=1e7;i++)
    {
        if(prime[i]==i)
        {
            for(ll j=i;j<=1e7;j+=i)
            {
                prime[j]=i;
                num[i]+=cnt[j];
            }
        }
    }
}

int main()
{
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>x;
        cnt[x]++;
    }
    primal();
    for(ll i=2;i<=1e7;i++)
        num[i]+=num[i-1];
    // cout<<num[2]<<" "<<num[3]<<" "<<num[5]<<" "<<num[7]<<" "<<num[11]<<endl;
    cin>>m;
    while(m--)
    {
        cin>>l>>r;
        if (l>=1e7)l=1e7-1;
		if (r>=1e7)r=1e7-1;
        cout<<num[r]-num[l-1]<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
#define ff first
#define ss second
ll n,m,l,r;
ll arr[1000005],cnt[7000005];
ll prime[7000005];

void primal()
{
    prime[0]=0;prime[1]=1;
    for(ll i=2;i<=1e7;i++)
        prime[i]=i;
    for(ll i=2;i*i<=1e7;i++)
    {
        if(prime[i]==i)
        {
            for(ll j=i*i;j<=1e7;j+=i)
                prime[j]=i;
        }
    }
}

void check(ll x)
{
    while(x>1)
    {
        ll temp=prime[x];
        cnt[temp]++;
        while(x%temp==0)
        {
            x/=temp;
        }
    }
}

int main()
{
    primal();
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
        check(arr[i]);
    }
    for(ll i=1;i<=1e7;i++)
        cnt[i]+=cnt[i-1];
    cin>>m;
    while(m--)
    {
        cin>>l>>r;
        cout<<cnt[r]-cnt[l-1]<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
#define ff first
#define ss second
ll n,m,l,r,x;
ll cnt[10000005],prime[10000005],num[10000005];

void primal()
{
    for(ll i=0;i<=1e7;i++)
        prime[i]=i;
    for(ll i=2;i<=1e7;i++)
    {
        if(prime[i]==i)
        {
            for(ll j=i;j<=1e7;j+=i)
            {
                prime[j]=i;
                num[i]+=cnt[j];
            }
        }
    }
}

int main()
{
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>x;
        cnt[x]++;
    }
    primal();
    for(ll i=2;i<=1e7;i++)
        num[i]+=num[i-1];
    // cout<<num[2]<<" "<<num[3]<<" "<<num[5]<<" "<<num[7]<<" "<<num[11]<<endl;
    cin>>m;
    while(m--)
    {
        cin>>l>>r;
        if(l>=1e7) l=1e7-1;
        if(r>=1e7) r=1e7-1;
        cout<<num[r]-num[l-1]<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
#define ff first
#define ss second
ll n,m,l,r;
ll arr[1000005],cnt[10000005];
ll prime[10000005],num[10000005];

void primal()
{
    prime[0]=0;prime[1]=1;
    for(ll i=2;i<=1e7;i++)
        prime[i]=i;
    for(ll i=2;i*i<=1e7;i++)
    {
        if(prime[i]==i)
        {
            for(ll j=i*i;j<=1e7;j+=i)
                prime[j]=i;
        }
    }
}

void check(ll x)
{
    ll temp2=cnt[x];
    while(x>1)
    {
        ll temp=prime[x];
        num[temp]+=temp2;
        while(x%temp==0)
        {
            x/=temp;
        }
    }
}

int main()
{
    primal();
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
        cnt[arr[i]]++;
    }
    for(int i=2;i<=1e7;i++)
    {
        if(cnt[i]>=1)
            check(i);
    }
    // cout<<num[2]<<" "<<num[3]<<" "<<num[5]<<" "<<num[7]<<" "<<num[11]<<endl;
    for(ll i=2;i<=1e7;i++)
        num[i]+=num[i-1];
    cin>>m;
    // cout<<num[2]<<" "<<num[3]<<" "<<num[5]<<" "<<num[7]<<" "<<num[11]<<endl;
    while(m--)
    {
        cin>>l>>r;
        cout<<num[r]-num[l-1]<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
#define ff first
#define ss second
ll n,m,l,r,x;
ll cnt[10000005],prime[10000005],num[10000005];

void primal()
{
    for(ll i=0;i<=1e7;i++)
        prime[i]=i;
    for(ll i=2;i*i<=1e7;i++)
    {
        if(prime[i]==i)
        {
            for(ll j=i*i;j<=1e7;j+=i)
            {
                prime[j]=i;
                num[i]+=cnt[j];
            }
        }
    }
}

int main()
{
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>x;
        cnt[x]++;
    }
    primal();
    for(ll i=2;i<=1e7;i++)
        num[i]+=num[i-1];
    // cout<<num[2]<<" "<<num[3]<<" "<<num[5]<<" "<<num[7]<<" "<<num[11]<<endl;
    cin>>m;
    while(m--)
    {
        cin>>l>>r;
        if (l>=1e7)l=1e7-1;
		if (r>=1e7)r=1e7-1;
        cout<<num[r]-num[l-1]<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
#define ff first
#define ss second
ll n,m,l,r;
ll arr[1000005],cnt[10000005];
ll prime[10000005];

void primal()
{
    prime[0]=0;prime[1]=1;
    for(ll i=2;i<=1e7;i++)
        prime[i]=i;
    for(ll i=2;i*i<=1e7;i++)
    {
        if(prime[i]==i)
        {
            for(ll j=i*i;j<=1e7;j+=i)
                prime[j]=i;
        }
    }
}

void check(ll x)
{
    while(x>1)
    {
        ll temp=prime[x];
        cnt[temp]++;
        while(x%temp==0)
        {
            x/=temp;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    primal();
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
        // cnt[arr[i]]++;
        check(arr[i]);
    }
    for(ll i=1;i<=1e7;i++)
        cnt[i]+=cnt[i-1];
    // cout<<cnt[2]<<" "<<cnt[3]<<" "<<cnt[5]<<" "<<cnt[7]<<" "<<cnt[11]<<endl;
    cin>>m;
    while(m--)
    {
        cin>>l>>r;
        if(l>=1e7) l=1e7-1;
        if(r>=1e7) r=1e7-1;
        // cout<<"l "<<cnt[l]<<endl;
        // cout<<"r "<<cnt[r]<<endl;
        cout<<cnt[r]-cnt[l-1]<<endl;
    }
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x << " " << x << endl
#define ll long long
ll sum[10000010],mini[10000010],ara[1000005];
bool mark[10000010];
void seive()
{
    for(ll i=2; i<=10000010; i+=2)
        mark[i] = true,mini[i] = 2;
    ll lim = sqrt(10000010);
    for(ll i=3; i*i<10000010; i+=2)
    {
        if(!mark[i])
        {
            mini[i] = i;
            for(ll j = i*i; j<10000010; j+=i)
            {
                if(!mark[j])
                    mini[j] = i;
                mark[j] = true;
            }
        }
    }
}

void summ(ll x)
{

    set<ll> s;
    //debug(x);
    while(x>1)
    {
        if(!mark[x])
        {
            s.insert(x);
            break;
        }
        s.insert(mini[x]);

        //debug(mini[x]);
        x/=mini[x];
    }
    for(ll x:s)
        sum[x]++;
}

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

    seive();
    ll n,a;
    cin >> n;
    for(ll i=0; i<n; i++)
        cin >> ara[i];
    for(ll i=0; i<n; i++)
        summ(ara[i]);
    for(ll i=2; i<10000005; i++)
        sum[i]+=sum[i-1];
    ll m;
    cin >> m;
    for(ll i=0; i<m; i++)
    {
        ll a,b;
        cin >> a >> b;
        if(a>=10000000)
        {
            cout << 0 << endl;
            continue;
        }
        b = min(b,10000000LL);
        cout << sum[b]-sum[a-1] << endl;
    }
}