//Khodaya aghideye man ra az dast oghde am masoon dar!
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, greater_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
#pragma optimize O3
const int MOD = (int)1e9 + 7;
const int MAXN = (int)2e5 + 2;
const int MAX_SEG = (int)3e6 + 3;
const int infint = (ll)1e9;
const ll inf = (ll)1e18;
int pos[MAXN];
vector<int> pc[MAXN];
pair<int, int> P[MAX_SEG];
int xs[MAX_SEG];
int seg[4 * MAXN], ans[MAXN];
vector<pair<pair<int, int> , int> > Q;
void add(int node, int st, int en, int idx)
{
	if(en - st < 2)
	{
		seg[node]++;
		return;
	}
	int mid = (st + en) >> 1;
	if(st <= idx && idx < mid)
		add(node << 1, st, mid, idx);
	else
		add(node << 1 | 1, mid, en, idx);
	seg[node] = seg[node << 1] + seg[node << 1 | 1];
}
int get(int node, int st, int en, int l, int r)
{
	if(st >= r || l >= en)
		return 0;
	if(l <= st && en <= r)
		return seg[node];
	int mid = (st + en) >> 1;
	return get(node << 1, st, mid, l, r) + get(node << 1 | 1, mid, en, l, r);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		int a;
		cin >> a;
		pos[a] = i;
	}
	for (int i = 1; i <= n; i++)
		for (int j = i; j <= n; j += i)
		{
			int u = pos[i], v = pos[j];
			if(u > v)
				swap(u, v);
			pc[u].push_back(v);
		}
	for (int i = 1; i <= n; i++)
		sort(pc[i].begin(), pc[i].end());
	int t = 0;
	for (int i = 1; i <= n; i++)
	{
		for (auto u : pc[i])
			P[t++] = {i, u};
	}
	for (int i = 0; i < t; i++)
		xs[i] = P[i].first;

	for (int i = 0; i < m; i++)
	{
		int l, r;
		cin >> l >> r;
		Q.push_back({ {l, r}, i});
	}
	sort(Q.begin(), Q.end());
	int ptr = t - 1;
	for (int i = m - 1; i >= 0; i--)
	{
		while(ptr >= 0 && P[ptr].first >= Q[i].first.first)
		{
			add(1, 0, MAXN, P[ptr].second);
			ptr--;
		}
		ans[Q[i].second] = get(1, 0, MAXN, 1, Q[i].first.second + 1);
	}
	for (int i = 0; i < m; i++)
		cout << ans[i] << "\n";
}


//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

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

using namespace std;

#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcount
#define sqr(x) ((x) * (x))
#define al 0x3F3F3F3F
#define sz(x) x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos(-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

vector <int> v[N];
vector <pii> q[N];
int n, m, p[N], pos[N], a[N], ans[N], t[4 * N];

void upd (int Pos, int val, int v = 1, int tl = 1, int tr = n) {
	if (tl == tr) {
		t[v] += val;
		return;
	}
	int tm = tl + tr >> 1;
	if (Pos <= tm) upd (Pos, val, v + v, tl, tm);
	else upd (Pos, val, v + v + 1, tm + 1, tr);
	t[v] = t[v + v] + t[v + v + 1];
}

int get (int l, int r, int v = 1, int tl = 1, int tr = n) {
	if (tl > r || tr < l) return 0;
	if (l <= tl && tr <= r) return t[v];
	int tm = tl + tr >> 1;
	return get (l, r, v + v, tl, tm) + get (l, r, v + v + 1, tm + 1, tr);
}

inline void boost () {
	ios_base :: sync_with_stdio (NULL);
	cin.tie (NULL), cout.tie (NULL);
}

inline void Solve () {
	boost ();
	cin >> n >> m;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		pos[a[i]] = i;
	}
	for (int i = 1; i <= n; i ++) {
		for (int j = a[i]; j <= n; j += a[i]) {
			if (pos[j]) {
			//	cout << min (i, pos[j]) << ' ' << max (pos[j], i) << endl;
				v[max (pos[j], i)].pb (min (pos[j], i));
			}
		}
	}
	int l, r;
	for (int i = 1; i <= m; i ++) {
		cin >> l >> r;
		q[r].pb ({l, i});
	}
	for (int i = 1; i <= n; i ++) {
		for (auto it : v[i]) {
		//	cout << it << ' ';
			upd (it, 1);
		}
		for (auto it : q[i]) {
		//	cout << it.F << ' ' << i << ' ' << get (it.F, i) << endl;
			ans[it.S] = get (it.F, i);
		}
	}

	for (int i = 1; i <= m; i ++) cout << ans[i] << endl;

}

main () {
//	freopen ("ormax.in", "r", stdin);
//	freopen ("ormax.out", "w", stdout);
	int tt = 1;
//	cin >> tt;
	while (tt --) {
		Solve ();
	}
	return 0;
}


#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

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

using namespace std;

#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcount
#define sqr(x) ((x) * (x))
#define al 0x3F3F3F3F
#define sz(x) x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos(-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

vector <int> v[N];
vector <pii> q[N];
int n, m, p[N], pos[N], a[N], ans[N], t[4 * N];

void upd (int Pos, int val, int v = 1, int tl = 1, int tr = n) {
	if (tl == tr) {
		t[v] += val;
		return;
	}
	int tm = tl + tr >> 1;
	if (Pos <= tm) upd (Pos, val, v + v, tl, tm);
	else upd (Pos, val, v + v + 1, tm + 1, tr);
	t[v] = t[v + v] + t[v + v + 1];
}

int get (int l, int r, int v = 1, int tl = 1, int tr = n) {
	if (tl > r || tr < l) return 0;
	if (l <= tl && tr <= r) return t[v];
	int tm = tl + tr >> 1;
	return get (l, r, v + v, tl, tm) + get (l, r, v + v + 1, tm + 1, tr);
}

inline void boost () {
	ios_base :: sync_with_stdio (NULL);
	cin.tie (NULL), cout.tie (NULL);
}

inline void Solve () {
	boost ();
	cin >> n >> m;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		pos[a[i]] = i;
	}
	for (int i = 1; i <= n; i ++) {
		for (int j = a[i]; j <= n; j += a[i]) {
			if (pos[j]) {
			//	cout << min (i, pos[j]) << ' ' << max (pos[j], i) << endl;
				v[max (pos[j], i)].pb (min (pos[j], i));
			}
		}
	}
	int l, r;
	for (int i = 1; i <= m; i ++) {
		cin >> l >> r;
		q[r].pb ({l, i});
	}
	for (int i = 1; i <= n; i ++) {
		for (auto it : v[i]) {
		//	cout << it << ' ';
			upd (it, 1);
		}
		for (auto it : q[i]) {
		//	cout << it.F << ' ' << i << ' ' << get (it.F, i) << endl;
			ans[it.S] = get (it.F, i);
		}
	}

	for (int i = 1; i <= m; i ++) cout << ans[i] << endl;

}

main () {
//	freopen ("ormax.in", "r", stdin);
//	freopen ("ormax.out", "w", stdout);
	int tt = 1;
//	cin >> tt;
	while (tt --) {
		Solve ();
	}
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx")

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

using namespace std;

#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcount
#define sqr(x) ((x) * (x))
#define al 0x3F3F3F3F
#define sz(x) x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos(-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

vector <int> v[N];
vector <pii> q[N];
int n, m, p[N], pos[N], a[N], ans[N], t[4 * N];

void upd (int Pos, int val, int v = 1, int tl = 1, int tr = n) {
	if (tl == tr) {
		t[v] += val;
		return;
	}
	int tm = tl + tr >> 1;
	if (Pos <= tm) upd (Pos, val, v + v, tl, tm);
	else upd (Pos, val, v + v + 1, tm + 1, tr);
	t[v] = t[v + v] + t[v + v + 1];
}

int get (int l, int r, int v = 1, int tl = 1, int tr = n) {
	if (tl > r || tr < l) return 0;
	if (l <= tl && tr <= r) return t[v];
	int tm = tl + tr >> 1;
	return get (l, r, v + v, tl, tm) + get (l, r, v + v + 1, tm + 1, tr);
}

inline void boost () {
	ios_base :: sync_with_stdio (NULL);
	cin.tie (NULL), cout.tie (NULL);
}

inline void Solve () {
	boost ();
	cin >> n >> m;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		pos[a[i]] = i;
	}
	for (int i = 1; i <= n; i ++) {
		for (int j = a[i]; j <= n; j += a[i]) {
			if (pos[j]) {
			//	cout << min (i, pos[j]) << ' ' << max (pos[j], i) << endl;
				v[max (pos[j], i)].pb (min (pos[j], i));
			}
		}
	}
	int l, r;
	for (int i = 1; i <= m; i ++) {
		cin >> l >> r;
		q[r].pb ({l, i});
	}
	for (int i = 1; i <= n; i ++) {
		for (auto it : v[i]) {
		//	cout << it << ' ';
			upd (it, 1);
		}
		for (auto it : q[i]) {
		//	cout << it.F << ' ' << i << ' ' << get (it.F, i) << endl;
			ans[it.S] = get (it.F, i);
		}
	}

	for (int i = 1; i <= m; i ++) cout << ans[i] << endl;

}

main () {
//	freopen ("ormax.in", "r", stdin);
//	freopen ("ormax.out", "w", stdout);
	int tt = 1;
//	cin >> tt;
	while (tt --) {
		Solve ();
	}
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

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

using namespace std;

#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcount
#define sqr(x) ((x) * (x))
#define al 0x3F3F3F3F
#define sz(x) x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos(-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

vector <int> v[N];
vector <pii> q[N];
int n, m, p[N], pos[N], a[N], ans[N], t[4 * N];

void upd (int Pos, int val, int v = 1, int tl = 1, int tr = n) {
	if (tl == tr) {
		t[v] += val;
		return;
	}
	int tm = tl + tr >> 1;
	if (Pos <= tm) upd (Pos, val, v + v, tl, tm);
	else upd (Pos, val, v + v + 1, tm + 1, tr);
	t[v] = t[v + v] + t[v + v + 1];
}

int get (int l, int r, int v = 1, int tl = 1, int tr = n) {
	if (tl > r || tr < l) return 0;
	if (l <= tl && tr <= r) return t[v];
	int tm = tl + tr >> 1;
	return get (l, r, v + v, tl, tm) + get (l, r, v + v + 1, tm + 1, tr);
}

inline void boost () {
	ios_base :: sync_with_stdio (NULL);
	cin.tie (NULL), cout.tie (NULL);
}

inline void Solve () {
	boost ();
	cin >> n >> m;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		pos[a[i]] = i;
	}
	for (int i = 1; i <= n; i ++) {
		for (int j = a[i]; j <= n; j += a[i]) {
			if (pos[j]) {
			//	cout << min (i, pos[j]) << ' ' << max (pos[j], i) << endl;
				v[max (pos[j], i)].pb (min (pos[j], i));
			}
		}
	}
	int l, r;
	for (int i = 1; i <= m; i ++) {
		cin >> l >> r;
		q[r].pb ({l, i});
	}
	for (int i = 1; i <= n; i ++) {
		for (auto it : v[i]) {
		//	cout << it << ' ';
			upd (it, 1);
		}
		for (auto it : q[i]) {
		//	cout << it.F << ' ' << i << ' ' << get (it.F, i) << endl;
			ans[it.S] = get (it.F, i);
		}
	}

	for (int i = 1; i <= m; i ++) cout << ans[i] << endl;

}

main () {
//	freopen ("ormax.in", "r", stdin);
//	freopen ("ormax.out", "w", stdout);
	int tt = 1;
//	cin >> tt;
	while (tt --) {
		Solve ();
	}
	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

typedef pair <int, int> pii;
const long long INF = 1e18;
const int mod = 1e9 + 7;//1e9 + 7;//786433;//998244353;
const double Pi = acos(-1);

void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, m;
int p[200005], a[200005];
vector <int> U[200005];
vector <pair <int, int> > Query[200005];
long long BIT[200005], ans[200005];

void Update(int node)
{
	for(node; node <= n; node += node & -node)
	{
		BIT[node]++;
	}
}

long long Get(int node)
{
	long long ans = 0;
	for(node; node > 0; node -= node & -node)
	{
		ans += BIT[node];
	}
	return ans;
}

signed main()
{
	Fastio();
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		int temp;
		cin >> temp;
		a[i] = temp;
		p[temp] = i;
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = i; j <= n; j = j + i)
		{
			U[min(p[i], p[j])].eb(max(p[i], p[j]));
		}
	}
	for(int i = 1; i <= m; i++)
	{
		int l, r;
		cin >> l >> r;
		Query[l].eb(mp(r, i));
	}
	for(int i = n; i >= 1; i--)
	{
		for(auto x : U[i])
		{
			Update(x);
		}
		for(auto x : Query[i])
		{
			ans[x.se] = Get(x.fi) - Get(i - 1);
		}
	}
	for(int i = 1; i <= m; i++)
	{
		cout << ans[i] << '\n';
	}
}


#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

typedef pair <int, int> pii;
const long long INF = 1e18;
const int mod = 1e9 + 7;//1e9 + 7;//786433;//998244353;
const double Pi = acos(-1);

void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, m;
vector <pair <int, int> > Point;
int pos[200005], l[200005], r[200005];
vector <int> BIT[200005], Fake[200005];

void Fakeupdate(int x, int y)
{
	for(x; x <= n; x += x & -x)
	{
		Fake[x].eb(y);
	}
}

void Fakeget(int x, int y)
{
	if(x <= 0 or y <= 0)
	{
		return;
	}
	for(x; x > 0; x -= x & -x)
	{
		Fake[x].eb(y);
	}
}

void Build()
{
	for(int i = 1; i <= n; i++)
	{
		Fake[i].eb(1e9);
		sort(Fake[i].begin(), Fake[i].end());
		Fake[i].erase(unique(Fake[i].begin(), Fake[i].end()), Fake[i].end());
		BIT[i].resize((int)Fake[i].size() + 1, 0);
	}
}

void Update(int x, int y)
{
	if(x <= 0 or y <= 0)
	{
		return;
	}
	for(int i = x; i <= n; i += (i & -i))
	{
		for(int j = lower_bound(Fake[i].begin(), Fake[i].end(), y) - Fake[i].begin() + 1; j <= (int)Fake[i].size(); j += (j & -j))
		{
			BIT[i][j]++;
		}
	}
}

int Get(int x, int y)
{
	int ans = 0;
	if(x <= 0 or y <= 0)
	{
		return 0;
	}
	for(int i = x; i > 0; i -= (i & -i))
	{
		for(int j = upper_bound(Fake[i].begin(), Fake[i].end(), y) - Fake[i].begin(); j > 0; j -= (j & -j))
		{
			ans += BIT[i][j];
		}
	}
	return ans;
}

signed main()
{
//	Fastio();
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		int temp;
		cin >> temp;
		pos[temp] = i;
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = i * 2; j <= n; j = j + i)
		{
			Point.eb(mp(pos[i], pos[j]));
			Fakeupdate(pos[i], pos[j]);
		}
	}
	for(int i = 1; i <= m; i++)
	{
		cin >> l[i] >> r[i];
		Fakeget(l[i], r[i]);
		Fakeget(l[i] - 1, r[i]);
		Fakeget(l[i], r[i] - 1);
		Fakeget(l[i] - 1, l[i] - 1);
	}
	Build();
	for(auto x : Point)
	{
		Update(x.fi, x.se);
	}
	for(int i = 1; i <= m; i++)
	{
		cout << Get(r[i], r[i]) - Get(r[i], l[i] - 1) - Get(l[i] - 1, r[i]) + Get(l[i] - 1, l[i] - 1) + r[i] - l[i] + 1 << '\n';
	}
}


#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

typedef pair <int, int> pii;
const long long INF = 1e18;
const int mod = 1e9 + 7;//1e9 + 7;//786433;//998244353;
const double Pi = acos(-1);

void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, m;
int p[200005], a[200005];
vector <int> Div[200005];
vector <pair <int, int> > Query[200005];
long long BIT[200005], ans[200005];

void Update(int node)
{
	for(node; node <= n; node += node & -node)
	{
		BIT[node]++;
	}
}

long long Get(int node)
{
	long long ans = 0;
	for(node; node > 0; node -= node & -node)
	{
		ans += BIT[node];
	}
	return ans;
}

signed main()
{
	Fastio();
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		int temp;
		cin >> temp;
		a[i] = temp;
		p[temp] = i;
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= i; j++)
		{
			if(i % j == 0)
			{
				if(p[i] > p[j])
				{
					Div[j].eb(i);
				}
				else
				{
					Div[i].eb(j);
				}
			}
		}
	}
	for(int i = 1; i <= m; i++)
	{
		int l, r;
		cin >> l >> r;
		Query[l].eb(mp(r, i));
	}
	for(int i = n; i >= 1; i--)
	{
		for(auto x : Div[a[i]])
		{
			Update(x);
		}
		for(auto x : Query[i])
		{
			ans[x.se] = Get(x.fi) - Get(i - 1);
		}
	}
	for(int i = 1; i <= m; i++)
	{
		cout << ans[i] << '\n';
	}
}


#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

typedef pair <int, int> pii;
const long long INF = 1e18;
const int mod = 1e9 + 7;//1e9 + 7;//786433;//998244353;
const double Pi = acos(-1);

void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, m;
vector <pair <int, int> > Point;
int pos[200005], l[200005], r[200005];
vector <int> BIT[200005], Fake[200005];

void Fakeupdate(int x, int y)
{
	for(x; x <= n; x += x & -x)
	{
		Fake[x].eb(y);
	}
}

void Fakeget(int x, int y)
{
	if(x <= 0 or y <= 0)
	{
		return;
	}
	for(x; x > 0; x -= x & -x)
	{
		Fake[x].eb(y);
	}
}

void Build()
{
	for(int i = 1; i <= n; i++)
	{
		Fake[i].eb(1e9);
		sort(Fake[i].begin(), Fake[i].end());
		Fake[i].erase(unique(Fake[i].begin(), Fake[i].end()), Fake[i].end());
		BIT[i].resize((int)Fake[i].size() + 1, 0);
	}
}

void Update(int x, int y)
{
	if(x <= 0 or y <= 0)
	{
		return;
	}
	for(int i = x; i <= n; i += (i & -i))
	{
		for(int j = lower_bound(Fake[i].begin(), Fake[i].end(), y) - Fake[i].begin() + 1; j <= (int)Fake[i].size(); j += (j & -j))
		{
			BIT[i][j]++;
		}
	}
}

int Get(int x, int y)
{
	int ans = 0;
	if(x <= 0 or y <= 0)
	{
		return 0;
	}
	for(int i = x; i > 0; i -= (i & -i))
	{
		for(int j = upper_bound(Fake[i].begin(), Fake[i].end(), y) - Fake[i].begin(); j > 0; j -= (j & -j))
		{
			ans += BIT[i][j];
		}
	}
	return ans;
}

signed main()
{
	Fastio();
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		int temp;
		cin >> temp;
		pos[temp] = i;
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = i * 2; j <= n; j = j + i)
		{
			Point.eb(mp(pos[i], pos[j]));
			Fakeupdate(pos[i], pos[j]);
		}
	}
	for(int i = 1; i <= m; i++)
	{
		cin >> l[i] >> r[i];
		Fakeget(l[i], r[i]);
		Fakeget(l[i] - 1, r[i]);
		Fakeget(l[i], r[i] - 1);
		Fakeget(l[i] - 1, l[i] - 1);
	}
	Build();
	for(auto x : Point)
	{
		Update(x.fi, x.se);
	}
	for(int i = 1; i <= m; i++)
	{
		cout << Get(r[i], r[i]) - Get(r[i], l[i] - 1) - Get(l[i] - 1, r[i]) + Get(l[i] - 1, l[i] - 1) + r[i] - l[i] + 1 << '\n';
	}
}


#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

typedef pair <int, int> pii;
const long long INF = 1e18;
const int mod = 1e9 + 7;//1e9 + 7;//786433;//998244353;
const double Pi = acos(-1);

void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, m;
int p[200005], a[200005];
vector <int> Div[200005];
vector <pair <int, int> > Query[200005];
long long BIT[200005], ans[200005];

void Update(int node)
{
	for(node; node <= n; node += node & -node)
	{
		BIT[node]++;
	}
}

long long Get(int node)
{
	long long ans = 0;
	for(node; node > 0; node -= node & -node)
	{
		ans += BIT[node];
	}
	return ans;
}

signed main()
{
//	Fastio();
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		int temp;
		cin >> temp;
		a[i] = temp;
		p[temp] = i;
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= i; j++)
		{
			if(i % j == 0)
			{
				Div[i].eb(j);
			}
		}
	}
	for(int i = 1; i <= m; i++)
	{
		int l, r;
		cin >> l >> r;
		Query[l].eb(mp(r, i));
	}
	for(int i = n; i >= 1; i--)
	{
		for(auto x : Div[i])
		{
			if(p[x] > i)
				Update(p[x]);
		}
		for(int j = a[i]; j <= n; j += a[i])
		{
			if(p[j] >= i)
				Update(p[j]);
		}
		for(auto x : Query[i])
		{
			ans[x.se] = Get(x.fi) - Get(i - 1);
		}
	}
	for(int i = 1; i <= m; i++)
	{
		cout << ans[i] << '\n';
	}
}


#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

typedef pair <int, int> pii;
const long long INF = 1e18;
const int mod = 1e9 + 7;//1e9 + 7;//786433;//998244353;
const double Pi = acos(-1);

void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, m;
int p[200005], a[200005];
vector <int> Div[200005];
vector <pair <int, int> > Query[200005];
long long BIT[200005], ans[200005];

void Update(int node)
{
	for(node; node <= n; node += node & -node)
	{
		BIT[node]++;
	}
}

long long Get(int node)
{
	long long ans = 0;
	for(node; node > 0; node -= node & -node)
	{
		ans += BIT[node];
	}
	return ans;
}

signed main()
{
	Fastio();
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		int temp;
		cin >> temp;
		a[i] = temp;
		p[temp] = i;
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= i; j++)
		{
			if(i % j == 0)
			{
				Div[i].eb(j);
			}
		}
	}
	for(int i = 1; i <= m; i++)
	{
		int l, r;
		cin >> l >> r;
		Query[l].eb(mp(r, i));
	}
	for(int i = n; i >= 1; i--)
	{
		for(auto x : Div[a[i]])
		{
			if(p[x] > i)
				Update(p[x]);
		}
		for(int j = a[i]; j <= n; j += a[i])
		{
			if(p[j] >= i)
				Update(p[j]);
		}
		for(auto x : Query[i])
		{
			ans[x.se] = Get(x.fi) - Get(i - 1);
		}
	}
	for(int i = 1; i <= m; i++)
	{
		cout << ans[i] << '\n';
	}
}


#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

typedef pair <int, int> pii;
const long long INF = 1e18;
const int mod = 1e9 + 7;//1e9 + 7;//786433;//998244353;
const double Pi = acos(-1);

void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, m;
int p[200005], a[200005];
vector <pair <int, int> > Query[200005];
long long BIT[200005], ans[200005];

void Update(int node)
{
	for(node; node <= n; node += node & -node)
	{
		BIT[node]++;
	}
}

long long Get(int node)
{
	long long ans = 0;
	for(node; node > 0; node -= node & -node)
	{
		ans += BIT[node];
	}
	return ans;
}

signed main()
{
//	Fastio();
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		int temp;
		cin >> temp;
		a[i] = temp;
		p[temp] = i;
	}
	for(int i = 1; i <= m; i++)
	{
		int l, r;
		cin >> l >> r;
		Query[l].eb(mp(r, i));
	}
	for(int i = n; i >= 1; i--)
	{
		for(int j = a[i]; j <= n; j += a[i])
		{
			Update(p[j]);
		}
		for(auto x : Query[i])
		{
			ans[x.se] = Get(x.fi) - Get(i - 1);
		}
	}
	for(int i = 1; i <= m; i++)
	{
		cout << ans[i] << '\n';
	}
}


#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

typedef pair <int, int> pii;
const long long INF = 1e18;
const int mod = 1e9 + 7;//1e9 + 7;//786433;//998244353;
const double Pi = acos(-1);

void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, m;
int p[200005], a[200005];
vector <int> Div[200005];
vector <pair <int, int> > Query[200005];
long long BIT[200005], ans[200005];

void Update(int node)
{
	for(node; node <= n; node += node & -node)
	{
		BIT[node]++;
	}
}

long long Get(int node)
{
	long long ans = 0;
	for(node; node > 0; node -= node & -node)
	{
		ans += BIT[node];
	}
	return ans;
}

signed main()
{
//	Fastio();
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		int temp;
		cin >> temp;
		a[i] = temp;
		p[temp] = i;
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= i; j++)
		{
			if(i % j == 0)
			{
				Div[i].eb(j);
			}
		}
	}
	for(int i = 1; i <= m; i++)
	{
		int l, r;
		cin >> l >> r;
		Query[l].eb(mp(r, i));
	}
	for(int i = n; i >= 1; i--)
	{
		for(auto x : Div[a[i]])
		{
			if(p[x] > i)
				Update(p[x]);
		}
		for(int j = a[i]; j <= n; j += a[i])
		{
			if(p[j] >= i)
				Update(p[j]);
		}
		for(auto x : Query[i])
		{
			ans[x.se] = Get(x.fi) - Get(i - 1);
		}
	}
	for(int i = 1; i <= m; i++)
	{
		cout << ans[i] << '\n';
	}
}


///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<double, null_type, less_equal<double>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define int long long
typedef long long ll;
typedef double dd;
typedef long double ldd;
typedef pair <int, int> pii;
typedef pair <pii , int> ppii;
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define f first
#define s second
#define sz(x) (int)x.size()
#define smin(x , y) x = min(x , y)
#define smax(x , y) x = max(x , y)
#define mp make_pair
#define all(x) x.begin() , x.end()
#define debug(x) cerr<< #x << " = " << x << endl
#define ddebug(x, y) cerr<< #x << " = " << x  << ", " << #y << " = " << y << endl
#define uop(x, y) pii(min(x, y), max(x, y))
#define mem(a, b) memset(a, b, sizeof a)
#define sq(x) (x) * (x)
const int mx = 2e5 + 10;
int fen[mx], n, a[mx], p[mx], l[mx], r[mx], ans[mx];
vector < int > d[mx], q[mx];
void add(int p){
	for(p++; p <= n; p += (p & -p))
		fen[p]++;
	return;
}
int get(int p){
	int ans = 0;
	for( ; p ; p -= (p & -p))
		ans += fen[p];
	return ans;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		p[a[i]] = i;
	}
	for(int i = 1; i <= n; i++)
		for(int j = i; j <= n; j += i)
			d[max(p[i] , p[j])].pb(min(p[i] , p[j]));
	for(int i = 0; i < m; i++){
		cin >> l[i] >> r[i];
		l[i]--;
		q[r[i]].pb(i);
	}
	for(int i = 0; i < n; i++){
		for(int u : d[i])
			add(u);
		for(int u : q[i + 1])
			ans[u] = get(r[u]) - get(l[u]);
	}
	for(int i = 0; i < m; i++)
		cout << ans[i] << '\n';
	return 0;
}


///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<double, null_type, less_equal<double>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define int long long
typedef long long ll;
typedef double dd;
typedef long double ldd;
typedef pair <int, int> pii;
typedef pair <pii , int> ppii;
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define f first
#define s second
#define sz(x) (int)x.size()
#define smin(x , y) x = min(x , y)
#define smax(x , y) x = max(x , y)
#define mp make_pair
#define all(x) x.begin() , x.end()
#define debug(x) cerr<< #x << " = " << x << endl
#define ddebug(x, y) cerr<< #x << " = " << x  << ", " << #y << " = " << y << endl
#define uop(x, y) pii(min(x, y), max(x, y))
#define mem(a, b) memset(a, b, sizeof a)
#define sq(x) (x) * (x)
const int mx = 2e5 + 10;
int fen[mx], n, a[mx], p[mx], l[mx], r[mx], ans[mx];
vector < int > d[mx], q[mx];
void add(int p){
	for(p++; p <= n; p += (p & -p))
		fen[p]++;
	return;
}
int get(int p){
	int ans = 0;
	for( ; p ; p -= (p & -p))
		ans += fen[p];
	return ans;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		p[a[i]] = i;
	}
	for(int i = 1; i <= n; i++)
		for(int j = i; j <= n; j += i)
			d[max(p[i] , p[j])].pb(min(p[i] , p[j]));
	for(int i = 0; i < m; i++){
		cin >> l[i] >> r[i];
		l[i]--;
		q[r[i]].pb(i);
	}
	for(int i = 0; i < n; i++){
		for(int u : d[i])
			add(u);
		for(int u : q[i + 1])
			ans[u] = get(r[u]) - get(l[u]);
	}
	for(int i = 0; i < m; i++)
		cout << ans[i] << endl;
	return 0;
}


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

#define io ios::sync_with_stdio(false)
#define pb push_back
#define pqueue priority_queue
#define fi first
#define se second
#define ls rt<<1
#define rs rt<<1|1
#define mid (l+r)/2
#define sz(x) (int)(x).size()
#define dbg(x) cout<<#x<<" --- "<<x<<endl
#define mst(x,a) memset(x,a,sizeof(x))
#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r; }
const int inf=0x7fffffff;
const int maxn=2e5+10;
ll t[maxn],ans[maxn];
vector<pii> a;
int pos[maxn];
int n,m;

int lowbit(int x){ return x&-x; }
void add(int p){ while(p<=n){ t[p]++;p+=lowbit(p); } }
ll qsum(int p){ ll res=0;while(p){ res+=t[p];p-=lowbit(p); }return res; }

struct qans{
	int x,y,id;
	bool f;
	qans(){}
	qans(int x,int y,int id,bool f):x(x),y(y),id(id),f(f){}
	bool operator<(const qans &u)const{
		return x<u.x;
	}
};

vector<qans> b;

int main(){
	io;
	cin>>n>>m;
	for(int i=1;i<=n;i++){ int x;cin>>x;pos[x]=i; }
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j+=i)
			a.pb(pii(pos[i],pos[j]));
	sort(a.begin(),a.end());
	for(int i=1;i<=m;i++){
		int l,r;cin>>l>>r;
		b.pb(qans(r,r,i,false));
		b.pb(qans(r,l-1,i,true));
		b.pb(qans(l-1,r,i,true));
		b.pb(qans(l-1,l-1,i,false));
	}
	sort(b.begin(),b.end());
	int p=0;
	for(int i=0;i<sz(b);i++){
		while(p<sz(a)&&a[p].fi<=b[i].x){ add(a[p].se);p++; }
		if(b[i].f)ans[b[i].id]-=qsum(b[i].y);
		else ans[b[i].id]+=qsum(b[i].y);
	}
	for(int i=1;i<=m;i++)cout<<ans[i]<<endl;
	return 0;
}


#include<bits/stdc++.h>

namespace IO {
    const int MT = 50 * 1024 * 1024;//50mb
    char IO_BUF[MT];
    int IO_PTR, IO_SZ;
    void begin() {
        IO_PTR = 0;
        IO_SZ = fread (IO_BUF, 1, MT, stdin);
    }
    template<typename T>
    inline bool scan_d (T & t) {
        while (IO_PTR < IO_SZ && IO_BUF[IO_PTR] != '-' && (IO_BUF[IO_PTR] < '0' || IO_BUF[IO_PTR] > '9'))
            IO_PTR ++;
        if (IO_PTR >= IO_SZ) return false;
        bool sgn = false;
        if (IO_BUF[IO_PTR] == '-') sgn = true, IO_PTR ++;
        for (t = 0; IO_PTR < IO_SZ && '0' <= IO_BUF[IO_PTR] && IO_BUF[IO_PTR] <= '9'; IO_PTR ++)
            t = t * 10 + IO_BUF[IO_PTR] - '0';
        if (sgn) t = -t;
        return true;
    }
    inline bool scan_s (char s[]) {
        while (IO_PTR < IO_SZ && (IO_BUF[IO_PTR] == ' ' || IO_BUF[IO_PTR] == '\n') ) IO_PTR ++;
        if (IO_PTR >= IO_SZ) return false;
        int len = 0;
        while (IO_PTR < IO_SZ && IO_BUF[IO_PTR] != ' ' && IO_BUF[IO_PTR] != '\n')
            s[len ++] = IO_BUF[IO_PTR], IO_PTR ++;
        s[len] = '\0';
        return true;
    }
    template<typename T>
    void print(T x) {
        static char s[33], *s1; s1 = s;
        if (!x) *s1++ = '0';
        if (x < 0) putchar('-'), x = -x;
        while(x) *s1++ = (x % 10 + '0'), x /= 10;
        while(s1-- != s) putchar(*s1);
    }
    template<typename T>
    void println(T x) {
        print(x); putchar('\n');
    }
};

using namespace IO;
using namespace std;

#define io ios::sync_with_stdio(false)
#define pb push_back
#define pqueue priority_queue
#define fi first
#define se second
#define ls rt<<1
#define rs rt<<1|1
#define mid (l+r)/2
#define sz(x) (int)(x).size()
#define dbg(x) cout<<#x<<" --- "<<x<<endl
#define mst(x,a) memset(x,a,sizeof(x))
#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r; }
const int inf=0x7fffffff;
const int maxn=2e5+10;
ll t[maxn],ans[maxn];
vector<pii> a;
int pos[maxn];
int n,m;

int lowbit(int x){ return x&-x; }
void add(int p){ while(p<=n){ t[p]++;p+=lowbit(p); } }
ll qsum(int p){ ll res=0;while(p){ res+=t[p];p-=lowbit(p); }return res; }

struct qans{
	int x,y,id;
	bool f;
	qans(){}
	qans(int x,int y,int id,bool f):x(x),y(y),id(id),f(f){}
	bool operator<(const qans &u)const{
		return x<u.x;
	}
};

vector<qans> b;

int main(){
	begin();
	// cin>>n>>m;
	scan_d(n);scan_d(m);
	for(int i=1;i<=n;i++){ int x;scan_d(x);pos[x]=i; }
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j+=i)
			a.pb(pii(pos[i],pos[j]));
	sort(a.begin(),a.end());
	for(int i=1;i<=m;i++){
		int l,r;scan_d(l);scan_d(r);
		// cin>>l>>r;
		b.pb(qans(r,r,i,false));
		b.pb(qans(r,l-1,i,true));
		b.pb(qans(l-1,r,i,true));
		b.pb(qans(l-1,l-1,i,false));
	}
	sort(b.begin(),b.end());
	int p=0;
	for(int i=0;i<sz(b);i++){
		while(p<sz(a)&&a[p].fi<=b[i].x){ add(a[p].se);p++; }
		if(b[i].f)ans[b[i].id]-=qsum(b[i].y);
		else ans[b[i].id]+=qsum(b[i].y);
	}
	for(int i=1;i<=m;i++)println(ans[i]);
		// cout<<ans[i]<<endl;
	return 0;
}


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

    #define io ios::sync_with_stdio(false)
    #define pb push_back
    #define pqueue priority_queue
    #define fi first
    #define se second
    #define ls rt<<1
    #define rs rt<<1|1
    #define mid (l+r)/2
    #define sz(x) (int)(x).size()
    #define dbg(x) cout<<#x<<" --- "<<x<<endl
    #define mst(x,a) memset(x,a,sizeof(x))
    #define fin(a) freopen(a,"r",stdin)
    #define fout(a) freopen(a,"w",stdout)
    typedef long long ll;
    typedef pair<int,int> pii;
    typedef pair<ll,ll> pll;
    ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
    ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r; }
    const int inf=0x7fffffff;
    const int maxn=2e5+10;
    ll t[maxn],ans[maxn];
    vector<pii> a;
    int pos[maxn];
    int n,m;

    int lowbit(int x){ return x&-x; }
    void add(int p){ while(p<=n){ t[p]++;p+=lowbit(p); } }
    ll qsum(int p){ ll res=0;while(p){ res+=t[p];p-=lowbit(p); }return res; }

    struct qans{
    	int x,y,id;
    	bool f;
    	qans(){}
    	qans(int x,int y,int id,bool f):x(x),y(y),id(id),f(f){}
    	bool operator<(const qans &u)const{
    		return x<u.x;
    	}
    };

    vector<qans> b;

    int main(){
    	io;
    	cin>>n>>m;
    	for(int i=1;i<=n;i++){ int x;cin>>x;pos[x]=i; }
    	for(int i=1;i<=n;i++)
    		for(int j=i;j<=n;j+=i)
    			a.pb(pii(pos[i],pos[j]));
    	sort(a.begin(),a.end());
    	for(int i=1;i<=m;i++){
    		int l,r;cin>>l>>r;
    		b.pb(qans(r,r,i,false));
    		b.pb(qans(r,l-1,i,true));
    		b.pb(qans(l-1,r,i,true));
    		b.pb(qans(l-1,l-1,i,false));
    	}
    	sort(b.begin(),b.end());
    	int p=0;
    	for(int i=0;i<sz(b);i++){
    		while(p<sz(a)&&a[p].fi<=b[i].x){ add(a[p].se);p++; }
    		if(b[i].f)ans[b[i].id]-=qsum(b[i].y);
    		else ans[b[i].id]+=qsum(b[i].y);
    	}
    	for(int i=1;i<=m;i++)cout<<ans[i]<<'\n';
    	return 0;
    }


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
int n;
int a[maxn], id[maxn];
ll c[maxn], ans[maxn];
struct node{ int x, y, id; } q1[maxn*30], q2[maxn];
bool cmp(node qq1,node qq2)
{
    return qq1.x == qq2.x ? qq1.y < qq2.y : qq1.x > qq2.x;
}
int lowbit(int x){ return x&(-x); }
void update(int k,int x)
{
    for(int i = k; i <= n; i += lowbit(i)) c[i] += x;
}
ll query(int k)
{
    ll res = 0;
    for(int i = k; i; i -= lowbit(i)) res += c[i];
    return res;
}
int main()
{
    int m, cnt = 0;
    scanf("%d%d",&n,&m);
    for(int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
        id[a[i]] = i;
    }
    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j += i){
            q1[++cnt] = (node){min(id[i],id[j]),max(id[i],id[j]),0};
        }
    }
    for(int i = 1; i <= m; i++){
        scanf("%d%d",&q2[i].x,&q2[i].y);
        q2[i].id = i;
    }
    sort(q1+1,q1+cnt+1,cmp);
    sort(q2+1,q2+m+1,cmp);
    int p = 1;
    for(int i = 1; i <= m; i++){
        while(p <= cnt && q1[p].x >= q2[i].x){
            update(q1[p].y,1);
            p++;
        }
        ans[q2[i].id] = query(q2[i].y);
    }
    for(int i = 1; i <= m; i++) printf("%lld\n",ans[i]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
int n;
int a[maxn], id[maxn];
ll c[maxn], ans[maxn];
struct node{ int x, y, id; } q1[maxn*2], q2[maxn];
bool cmp(node qq1,node qq2)
{
    return qq1.x == qq2.x ? qq1.y < qq2.y : qq1.x > qq2.x;
}
int lowbit(int x){ return x&(-x); }
void update(int k,int x)
{
    for(int i = k; i <= n; i += lowbit(i)) c[i] += x;
}
ll query(int k)
{
    ll res = 0;
    for(int i = k; i; i -= lowbit(i)) res += c[i];
    return res;
}
int main()
{
    int m, cnt = 0;
    scanf("%d%d",&n,&m);
    for(int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
        id[a[i]] = i;
    }
    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j += i){
            q1[++cnt] = (node){min(id[i],id[j]),max(id[i],id[j]),0};
        }
    }
    for(int i = 1; i <= m; i++){
        scanf("%d%d",&q2[i].x,&q2[i].y);
        q2[i].id = i;
    }
    sort(q1+1,q1+cnt+1,cmp);
    sort(q2+1,q2+m+1,cmp);
    int p = 1;
    for(int i = 1; i <= m; i++){
        while(p <= cnt && q1[p].x >= q2[i].x){
            update(q1[p].y,1);
            p++;
        }
        ans[q2[i].id] = query(q2[i].y);
    }
    for(int i = 1; i <= m; i++) printf("%lld\n",ans[i]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n;
int a[maxn], id[maxn], ans[maxn], c[maxn];
struct node{ int x, y, id; } q1[maxn], q2[maxn];
bool cmp(node qq1,node qq2)
{
    return qq1.x == qq2.x ? qq1.y < qq2.y : qq1.x > qq2.x;
}
int lowbit(int x){ return x&(-x); }
void update(int k,int x)
{
    for(int i = k; i <= n; i += lowbit(i)) c[i] += x;
}
int query(int k)
{
    int res = 0;
    for(int i = k; i; i -= lowbit(i)) res += c[i];
    return res;
}
int main()
{
    int m, cnt = 0;
    scanf("%d%d",&n,&m);
    for(int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
        id[a[i]] = i;
    }
    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j += i){
            q1[++cnt] = (node){min(id[i],id[j]),max(id[i],id[j]),0};
        }
    }
    for(int i = 1; i <= m; i++){
        scanf("%d%d",&q2[i].x,&q2[i].y);
        q2[i].id = i;
    }
    sort(q1+1,q1+cnt+1,cmp);
    sort(q2+1,q2+m+1,cmp);
    int p = 1;
    for(int i = 1; i <= m; i++){
        while(p <= cnt && q1[p].x >= q2[i].x){
            update(q1[p].y,1);
            p++;
        }
        ans[q2[i].id] = query(q2[i].y);
    }
    for(int i = 1; i <= m; i++) printf("%d\n",ans[i]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n;
int a[maxn], id[maxn], ans[maxn], c[maxn];
struct node{ int x, y, id; } q1[maxn*2], q2[maxn];
bool cmp(node qq1,node qq2)
{
    return qq1.x == qq2.x ? qq1.y < qq2.y : qq1.x > qq2.x;
}
int lowbit(int x){ return x&(-x); }
void update(int k,int x)
{
    for(int i = k; i <= n; i += lowbit(i)) c[i] += x;
}
int query(int k)
{
    int res = 0;
    for(int i = k; i; i -= lowbit(i)) res += c[i];
    return res;
}
int main()
{
    int m, cnt = 0;
    scanf("%d%d",&n,&m);
    for(int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
        id[a[i]] = i;
    }
    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j += i){
            q1[++cnt] = (node){min(id[i],id[j]),max(id[i],id[j]),0};
        }
    }
    for(int i = 1; i <= m; i++){
        scanf("%d%d",&q2[i].x,&q2[i].y);
        q2[i].id = i;
    }
    sort(q1+1,q1+cnt+1,cmp);
    sort(q2+1,q2+m+1,cmp);
    int p = 1;
    for(int i = 1; i <= m; i++){
        while(p <= cnt && q1[p].x >= q2[i].x){
            update(q1[p].y,1);
            p++;
        }
        ans[q2[i].id] = query(q2[i].y);
    }
    for(int i = 1; i <= m; i++) printf("%d\n",ans[i]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n;
int a[maxn], id[maxn], ans[maxn], c[maxn];
struct node{ int x, y, id; } q1[maxn], q2[maxn];
bool cmp(node qq1,node qq2)
{
    return qq1.x == qq2.x ? qq1.y < qq2.y : qq1.x > qq2.x;
}
int lowbit(int x){ return x&(-x); }
void update(int k,int x)
{
    for(int i = k; i <= n; i += lowbit(i)) c[i] += x;
}
int query(int k)
{
    int res = 0;
    for(int i = k; i; i -= lowbit(i)) res += c[i];
    return res;
}
int main()
{
    int m, cnt = 0;
    scanf("%d%d",&n,&m);
    for(int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
        id[a[i]] = i;
    }
    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j += i){
            q1[++cnt] = (node){min(id[i],id[j]),max(id[i],id[j]),0};
        }
    }
    for(int i = 1; i <= m; i++){
        scanf("%d%d",&q2[i].x,&q2[i].y);
        q2[i].id = i;
    }
    sort(q1+1,q1+cnt+1,cmp);
    sort(q2+1,q2+m+1,cmp);
    int p = 1;
    for(int i = 1; i <= m; i++){
        while(p <= cnt && q1[p].x >= q2[i].x){
            update(q1[p].y,1);
            p++;
        }
        ans[q2[i].id] = query(q2[i].y);
    }
    for(int i = 1; i <= m; i++) printf("%d\n",ans[i]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
int n;
int a[maxn], id[maxn];
int c[maxn], ans[maxn];
struct node{ int x, y, id; } q1[maxn*30], q2[maxn];
bool cmp(node qq1,node qq2)
{
    return qq1.x == qq2.x ? qq1.y < qq2.y : qq1.x > qq2.x;
}
int lowbit(int x){ return x&(-x); }
void update(int k,int x)
{
    for(int i = k; i <= n; i += lowbit(i)) c[i] += x;
}
int query(int k)
{
    int res = 0;
    for(int i = k; i; i -= lowbit(i)) res += c[i];
    return res;
}
int main()
{
    int m, cnt = 0;
    scanf("%d%d",&n,&m);
    for(int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
        id[a[i]] = i;
    }
    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j += i){
            q1[++cnt] = (node){min(id[i],id[j]),max(id[i],id[j]),0};
        }
    }
    for(int i = 1; i <= m; i++){
        scanf("%d%d",&q2[i].x,&q2[i].y);
        q2[i].id = i;
    }
    sort(q1+1,q1+cnt+1,cmp);
    sort(q2+1,q2+m+1,cmp);
    int p = 1;
    for(int i = 1; i <= m; i++){
        while(p <= cnt && q1[p].x >= q2[i].x){
            update(q1[p].y,1);
            p++;
        }
        ans[q2[i].id] = query(q2[i].y);
    }
    for(int i = 1; i <= m; i++) printf("%d\n",ans[i]);
    return 0;
}


/// You just can't beat the person who never gives up
/// ICPC next year

///#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std ;
const int N = 2e5+5 ;

int n ,m ,l ,r ,x ,idx[N] ;
vector<int> all[N] ;
vector<pair<pair<int,int>,int>> qry ;
int ans[N] ;

int tree[N];
int getSum(int i){
    if(i==-1) return -1;
    int res = 0;
    for(i++ ;i ;i -= i&(-i)) res += tree[i-1];
    return res;
}
void add(int i,int v){
    for(i++;i<=N;i += i&(-i)) tree[i-1] += v;
}
int lower_bound(int v){
    return getSum(v - 1) + 1;
}
int upper_bound(int v){
    return lower_bound(v + 1);
}
int cnt(int qs,int qe){
    return upper_bound(qe) - lower_bound(qs) ;
}
int main(){
    add(0,-1);
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;++i){
        scanf("%d",&x);
        idx[x] = i ;
    }
    for(int i=1;i<=n;++i) for(int j=i+i;j<=n;j+=i)
        all[max(idx[i],idx[j])].push_back(min(idx[i],idx[j]));

    for(int i=0;i<m;++i){
        scanf("%d%d",&l,&r);
        qry.push_back({{--r,--l},i});
    }
    sort(qry.begin(),qry.end());
    int cur = 0 ;
    for(auto go:qry){
        r = go.first.first ;
        l = go.first.second ;
        int i = go.second ;
        while(cur<=r){
            for(int j:all[cur]) add(j,1);
            ++cur ;
        }
        ans[i] = cnt(l,n-1)+(r-l+1) ;
    }
    for(int i=0;i<m;++i) printf("%d\n",ans[i]);
    return 0;
}


/// You just can't beat the person who never gives up
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 2e5+5 ;

int n ,m ,l ,r ,x ,idx[N] ;
vector<int> dvisor[N] ;
vector<pair<pair<int,int>,int>> q ;
long long ans[N] ,cur ;
int st ,en ;
void add(int qs,int qe,int v){
    cur += upper_bound(dvisor[v].begin(),dvisor[v].end(),qe) - lower_bound(dvisor[v].begin(),dvisor[v].end(),qs);
}
void rmv(int qs,int qe,int v){
    cur -= upper_bound(dvisor[v].begin(),dvisor[v].end(),qe) - lower_bound(dvisor[v].begin(),dvisor[v].end(),qs);
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;++i){
        scanf("%d",&x);
        idx[x] = i ;
    }
    for(int i=1;i<=n;++i) for(int j=i;j<=n;j+=i){
        dvisor[idx[i]].push_back(idx[j]);
        dvisor[idx[j]].push_back(idx[i]);
    }
    for(int i=0;i<n;++i){
        sort(dvisor[i].begin(),dvisor[i].end());
        dvisor[i].erase(unique(dvisor[i].begin(),dvisor[i].end()),dvisor[i].end());
    }
    for(int i=0;i<m;++i){
        scanf("%d%d",&l,&r);
        q.push_back({{--l,--r},i});
    }
    int sqr = sqrt(n) ;
    sort(q.begin(),q.end(),[sqr](auto a,auto b){
       return make_pair(a.first.first/sqr ,a.first.second) <  make_pair(b.first.first/sqr ,b.first.second);
    });
    for(auto go:q){
        int s = go.first.first ;
        int e = go.first.second ;
        int i = go.second ;
        while(en<=e){
            add(st,en,en);
            ++en ;
        }
        while(en>e+1){
            --en ;
            rmv(st,en,en);
        }
        while(st>s){
            --st ;
            add(st,en-1,st);
        }
        while(st<s){
            rmv(st,en-1,st);
            ++st ;
        }
        ans[i] = cur ;
    }
    for(int i=0;i<m;++i) printf("%lld\n",ans[i]);
    return 0;
}


/// You just can't beat the person who never gives up
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 2e5+5 ;

int n ,m ,l ,r ,a[N] ,idx[N] ;
vector<int> all[N] ;
vector<pair<pair<int,int>,int>> qry ;
long long ans[N] ,seg[1<<20];
void add(int i,int ni=0,int ns=0,int ne=n-1){
    if(ns==ne && ns==i) ++seg[ni] ;
    if(ne<i || ns>i || ns>=ne) return ;
    int l = ni*2+1 ,r = l+1 ,mid = (ns+ne)/2 ;
    add(i,l,ns,mid);
    add(i,r,mid+1,ne);
    seg[ni] = seg[l] + seg[r] ;
}
long long cnt(int qs,int qe,int ni=0,int ns=0,int ne=n-1){
    if(ns>=qs && ne<=qe) return seg[ni] ;
    if(ne<qs || ns>qe || ns>ne) return 0;
    int l = ni*2+1 ,r = l+1 ,mid = (ns+ne)/2 ;
    return cnt(qs,qe,l,ns,mid) + cnt(qs,qe,r,mid+1,ne) ;
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;++i){
        scanf("%d",a+i);
        idx[a[i]] = i ;
    }
    for(int i=1;i<=n;++i) for(int j=i;j<=n;j+=i)
        all[max(idx[i],idx[j])].push_back(min(idx[i],idx[j]));

    for(int i=0;i<m;++i){
        scanf("%d%d",&l,&r);
        qry.push_back({{--r,--l},i});
    }
    sort(qry.begin(),qry.end());
    int cur = 0 ;
    for(auto go:qry){
        r = go.first.first ;
        l = go.first.second ;
        int i = go.second ;
        while(cur<=r){
            for(int j:all[cur]) add(j);
            ++cur ;
        }
        ans[i] = cnt(l,n-1) ;
    }
    for(int i=0;i<m;++i) printf("%lld\n",ans[i]);
    return 0;
}


/// You just can't beat the person who never gives up
/// ICPC next year

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std ;
const int N = 2e5+5 ;

int n ,m ,l ,r ,x ,idx[N] ;
vector<int> all[N] ;
vector<pair<pair<int,int>,int>> qry ;
int ans[N] ;

int tree[N];
int getSum(int i){
    if(i==-1) return -1;
    int res = 0;
    for(i++ ;i ;i -= i&(-i)) res += tree[i-1];
    return res;
}
void add(int i,int v){
    for(i++;i<=N;i += i&(-i)) tree[i-1] += v;
}
int lower_bound(int v){
    return getSum(v - 1) + 1;
}
int upper_bound(int v){
    return lower_bound(v + 1);
}
int cnt(int qs,int qe){
    return upper_bound(qe) - lower_bound(qs) ;
}
int main(){
    add(0,-1);
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;++i){
        scanf("%d",&x);
        idx[x] = i ;
    }
    for(int i=1;i<=n;++i) for(int j=i+i;j<=n;j+=i)
        all[max(idx[i],idx[j])].push_back(min(idx[i],idx[j]));

    for(int i=0;i<m;++i){
        scanf("%d%d",&l,&r);
        qry.push_back({{--r,--l},i});
    }
    sort(qry.begin(),qry.end());
    int cur = 0 ;
    for(auto go:qry){
        r = go.first.first ;
        l = go.first.second ;
        int i = go.second ;
        while(cur<=r){
            for(int j:all[cur]) add(j,1);
            ++cur ;
        }
        ans[i] = cnt(l,n-1)+(r-l+1) ;
    }
    for(int i=0;i<m;++i) printf("%d\n",ans[i]);
    return 0;
}


/*

Editorial:

প্রথমত ধরি আমার কাছে দুইটা নাম্বার আছে। এখন নাম্বার দুইটা কোনটা কোনটাকে নিঃশেষে ভাগ করে এটা কিন্তু আমার দরকার নাই। আমি শুধু নাম্বার দুইটা পাইলেই হইছে। তাই না?

এখন আমি একটা নির্দিষ্ট পজিশনের জন্য এর বাম পাশে কতগুলা নাম্বার আছে যেগুলো দিয়ে পেয়ার সম্ভব সেগুলো সেভ রাখলাম।

এবার আমি একটা জিনিষ খেয়াল করি, আমি কুয়েরি গুলা কিন্তু সেভ রাখতে পারবো। এখন আমি 1-n পর্যন্ত লুপ চালায়ে দেখবো i এর জন্য বামে কি কি পজিশন আছে বিভাজ্য। আর এমন কি কি কুয়েরি আছে যেই কুয়েরির রেঞ্জ শেষ হইছে i তম ইনডেক্সে। এখন আমি 1-i পজিশনের জন্য বামে যেসব নাম্বার পাইছি এর মধ্যে কয়টা l এর পরে আছে দেখলেই কি হচ্ছে না? যেহেতু আমি r এর বাইরে আমি এখনো আপডেট ই করি নাই। এখন এই চেকিং টা আমি সেটে বাইনারী সার্চ করেও করতে পারি, আবার বি আই টি দিয়েও করতে পারি। আমি বি আই টি প্রেফার করবো। সেট এ অনেক প্যারা খাইছি। :P

*/

// God put a smile upon your face <3

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

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 958585860497

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

vector < ll > graph[200005];
vector < pll > qq[200005];
ll tree[200005];
ll mp[200005];
ll arr[200005];

ll query(ll idx)
{
       ll sum=0;
       while(idx>0){
             sum+=tree[idx];
             idx -= idx & (-idx);
       }
       return sum;
}

void update(ll idx, ll x, ll n) //n is the size of the array, x is the number to add
{
       while(idx<=n)
       {
             tree[idx]+=x;
             idx += idx & (-idx);
       }
}

ll ans[200005];

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    slld(n);
    slld(m);

    for(i = 1; i <= n; i++)
    {
		slld(arr[i]);
		mp[arr[i]] = i;
    }

    for(i = 1; i <= m; i++)
    {
		slld(l);
		slld(r);

		qq[r].pb({l,i});
    }

    for(i = 1; i <= n; i++)
    {
		for(j = i; j <= n; j += i)
		{
			ll x = max(mp[i],mp[j]);
			ll y = min(mp[i],mp[j]);

			graph[x].push_back(y);
		}
    }

    for(i = 1; i <= n; i++)
    {
		for(auto it: graph[i])
		{
			update(it,1,n);
		}

		for(pll it: qq[i])
		{
			ans[it.second] = query(n) - query(it.first - 1);
		}
    }

    for(i = 1; i <= m; i++)
    {
		printf("%lld\n", ans[i]);
    }

}


// God put a smile upon your face <3

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

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 958585860497

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

vector < ll > graph[200005];
vector < pll > qq[200005];
ll tree[200005];
ll mp[200005];
ll arr[200005];

ll query(ll idx)
{
       ll sum=0;
       while(idx>0){
             sum+=tree[idx];
             idx -= idx & (-idx);
       }
       return sum;
}

void update(ll idx, ll x, ll n) //n is the size of the array, x is the number to add
{
       while(idx<=n)
       {
             tree[idx]+=x;
             idx += idx & (-idx);
       }
}

ll ans[200005];

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    slld(n);
    slld(m);

    for(i = 1; i <= n; i++)
    {
		slld(arr[i]);
		mp[arr[i]] = i;
    }

    for(i = 1; i <= m; i++)
    {
		slld(l);
		slld(r);

		qq[r].pb({l,i});
    }

    for(i = 1; i <= n; i++)
    {
		for(j = i; j <= n; j += i)
		{
			ll x = max(mp[i],mp[j]);
			ll y = min(mp[i],mp[j]);

			graph[x].push_back(y);
		}
    }

    for(i = 1; i <= n; i++)
    {
		for(auto it: graph[i])
		{
			update(it,1,n);
		}

		for(pll it: qq[i])
		{
			ans[it.second] = query(n) - query(it.first - 1);
		}
    }

    for(i = 1; i <= m; i++)
    {
		printf("%lld\n", ans[i]);
    }

}


/*input
10 9
1 2 3 4 5 6 7 8 9 10
1 10
2 9
3 8
4 7
5 6
2 2
9 10
5 10
4 10
*/
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
using namespace std;
#define TEMPLATE

#ifdef TEMPLATE
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;

#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

const int MOD = 1000000007;
const ll INF = std::numeric_limits<ll>::max();
const int MX = 100101;
const ld PI = 3.14159265358979323846264338327950288419716939937510582097494L;

template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }

template<typename T>
void print(vector<T> vec, string name = "") {
	cout << name;
	for (auto u : vec)
		cout << u << ' ';
	cout << '\n';
}

#endif

struct query {
	int l, r;
	int ind;
};

struct node {
	int l, r;
	int sum;
	node *left = NULL;
	node *right = NULL;
	node(int a, int b): l(a), r(b), sum(0) {
		if (l != r) {
			left = new node(l, (l + r) / 2);
			right = new node((l + r) / 2 + 1, r);
		}
	}

	void add(int pos, int val) {
		if (l == r) sum += val;
		else if (pos <= (l + r) / 2) left->add(pos, val);
		else right->add(pos, val);

		if (l != r) sum = left->sum + right->sum;
	}

	int get(int a, int b) {
		if (r < a or b < l) return 0;
		if (a <= l and r <= b) return sum;
		else return left->get(a, b) + right->get(a, b);
	}
};

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int N, Q;
	cin >> N >> Q;
	vi kur(N + 1);
	vi sk(N);
	vii edges(N);

	for (int i = 0; i < N; ++i)
	{
		cin >> sk[i];
		kur[sk[i]] = i;
	}

	for (int i = 0; i < N; ++i)
	{
		for (int j = 1; j * j <= sk[i]; ++j)
		{
			if (sk[i] % j != 0) continue;

			if (j * j == sk[i]) {
				int pos = kur[j];
				edges[min(i, pos)].push_back(max(i, pos));
			} else {
				for (int num : {sk[i] / j, j}) {
					int pos = kur[num];
					edges[min(i, pos)].push_back(max(i, pos));
				}
			}
		}
	}

	int a, b;
	vector<query> queries(Q);
	for (int i = 0; i < Q; ++i)
	{
		cin >> a >> b; a--; b--;
		queries[i] = {a, b, i};
	}

	sort(queries.begin(), queries.end(), [](const query & pir, const query & ant) {
		return pir.l < ant.l or (pir.l == ant.l and pir.r < ant.r);
	});

	node medis(0, N - 1);

	for (int i = N - 1; i >= queries[0].l; --i)
	{
		for (auto u : edges[i])
			medis.add(u, 1);
	}

	int k = queries[0].l;

	vi ats(Q);
	for (int i = 0; i < Q; ++i)
	{
		while (k < N and k < queries[i].l) {
			for (auto u : edges[k])
				medis.add(u, -1);
			k++;
		}
		ats[queries[i].ind] = medis.get(queries[i].l, queries[i].r);
	}

	for (auto u : ats)
		printf("%d\n", u);
}

/* Look for:
* special cases (n=1?)
* overflow (ll vs int?)
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* array bounds
*/


/*input
10 9
1 2 3 4 5 6 7 8 9 10
1 10
2 9
3 8
4 7
5 6
2 2
9 10
5 10
4 10
*/
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
using namespace std;
#define TEMPLATE

#ifdef TEMPLATE
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;

#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

const int MOD = 1000000007;
const ll INF = std::numeric_limits<ll>::max();
const int MX = 100101;
const ld PI = 3.14159265358979323846264338327950288419716939937510582097494L;

template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }

template<typename T>
void print(vector<T> vec, string name = "") {
	cout << name;
	for (auto u : vec)
		cout << u << ' ';
	cout << '\n';
}

#endif

struct query {
	int l, r;
	int ind;
};

struct FENWICK {
	vi A;
	int N;
	FENWICK(int n): N(n) {
		A.resize(n + 1, 0);
	}
	void add(int i, int x) {
		for (; i <= N; i += (i) & (-i))
			A[i] += x;
	}

	int get(int a, int b) {
		return getQ(b) - getQ(a - 1);
	}

	int getQ(int i) {
		int get = 0;
		for (; i > 0; i -= (i) & (-i))
			get += A[i];
		return get;
	}
};

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int N, Q;
	cin >> N >> Q;
	vi kur(N + 1);
	vi sk(N + 1);
	vii edges(N + 1);

	for (int i = 1; i <= N; ++i)
	{
		cin >> sk[i];
		kur[sk[i]] = i;
	}

	for (int i = 1; i <= N; ++i)
	{
		for (int j = 1; j * j <= sk[i]; ++j)
		{
			if (sk[i] % j != 0) continue;

			if (j * j == sk[i]) {
				int pos = kur[j];
				edges[min(i, pos)].push_back(max(i, pos));
			} else {
				for (int num : {sk[i] / j, j}) {
					int pos = kur[num];
					edges[min(i, pos)].push_back(max(i, pos));
				}
			}
		}
	}

	int a, b;
	vector<query> queries(Q);
	for (int i = 0; i < Q; ++i)
	{
		cin >> a >> b;
		queries[i] = {a, b, i};
	}

	sort(queries.begin(), queries.end(), [](const query & pir, const query & ant) {
		return pir.l < ant.l or (pir.l == ant.l and pir.r < ant.r);
	});

	FENWICK medis(N);

	for (int i = N; i >= queries[0].l; --i)
	{
		for (auto u : edges[i])
			medis.add(u, 1);
	}

	int k = queries[0].l;

	vl ats(Q);
	for (int i = 0; i < Q; ++i)
	{
		while (k <= N and k < queries[i].l) {
			for (auto u : edges[k])
				medis.add(u, -1);
			k++;
		}
		ats[queries[i].ind] = medis.get(queries[i].l, queries[i].r);
	}

	for (auto u : ats)
		printf("%lld\n", u);
}

/* Look for:
* special cases (n=1?)
* overflow (ll vs int?)
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* array bounds
*/


/*input
10 9
1 2 3 4 5 6 7 8 9 10
1 10
2 9
3 8
4 7
5 6
2 2
9 10
5 10
4 10
*/
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
using namespace std;
#define TEMPLATE

#ifdef TEMPLATE
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;

#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

const int MOD = 1000000007;
const ll INF = std::numeric_limits<ll>::max();
const int MX = 100101;
const ld PI = 3.14159265358979323846264338327950288419716939937510582097494L;

template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }

template<typename T>
void print(vector<T> vec, string name = "") {
	cout << name;
	for (auto u : vec)
		cout << u << ' ';
	cout << '\n';
}

#endif

struct query {
	int l, r;
	int ind;
};

struct node {
	int l, r;
	ll sum;
	node *left = NULL;
	node *right = NULL;
	node(int a, int b): l(a), r(b), sum(0) {
		if (l != r) {
			left = new node(l, (l + r) / 2);
			right = new node((l + r) / 2 + 1, r);
		}
	}

	void add(int pos, ll val) {
		if (l == r) sum += val;
		else if (pos <= (l + r) / 2) left->add(pos, val);
		else right->add(pos, val);

		if (l != r) sum = left->sum + right->sum;
	}

	ll get(int a, int b) {
		if (r < a or b < l) return 0;
		if (a <= l and r <= b) return sum;
		else return left->get(a, b) + right->get(a, b);
	}
};

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int N, Q;
	cin >> N >> Q;
	vi kur(N + 1);
	vi sk(N);
	vii edges(N);

	for (int i = 0; i < N; ++i)
	{
		cin >> sk[i];
		kur[sk[i]] = i;
	}

	for (int i = 0; i < N; ++i)
	{
		for (int j = 1; j * j <= sk[i]; ++j)
		{
			if (sk[i] % j != 0) continue;

			if (j * j == sk[i]) {
				int pos = kur[j];
				edges[min(i, pos)].push_back(max(i, pos));
			} else {
				for (int num : {sk[i] / j, j}) {
					int pos = kur[num];
					edges[min(i, pos)].push_back(max(i, pos));
				}
			}
		}
	}

	int a, b;
	vector<query> queries(Q);
	for (int i = 0; i < Q; ++i)
	{
		cin >> a >> b; a--; b--;
		queries[i] = {a, b, i};
	}

	sort(queries.begin(), queries.end(), [](const query & pir, const query & ant) {
		return pir.l < ant.l or (pir.l == ant.l and pir.r < ant.r);
	});

	node medis(0, N - 1);

	for (int i = N - 1; i >= queries[0].l; --i)
	{
		for (auto u : edges[i])
			medis.add(u, 1);
	}

	int k = queries[0].l;

	vl ats(Q);
	for (int i = 0; i < Q; ++i)
	{
		while (k < N and k < queries[i].l) {
			for (auto u : edges[k])
				medis.add(u, -1);
			k++;
		}
		ats[queries[i].ind] = medis.get(queries[i].l, queries[i].r);
	}

	for (auto u : ats)
		printf("%lld\n", u);
}

/* Look for:
* special cases (n=1?)
* overflow (ll vs int?)
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* array bounds
*/


/*input
10 9
1 2 3 4 5 6 7 8 9 10
1 10
2 9
3 8
4 7
5 6
2 2
9 10
5 10
4 10
*/
#include <bits/stdc++.h>
using namespace std;
#define TEMPLATE

#ifdef TEMPLATE
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;

#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

const int MOD = 1000000007;
const ll INF = std::numeric_limits<ll>::max();
const int MX = 100101;
const ld PI = 3.14159265358979323846264338327950288419716939937510582097494L;

template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }

template<typename T>
void print(vector<T> vec, string name = "") {
	cout << name;
	for (auto u : vec)
		cout << u << ' ';
	cout << '\n';
}

#endif

struct query {
	int l, r;
	int ind;
};

struct node {
	int l, r;
	int sum;
	node *left = NULL;
	node *right = NULL;
	node(int a, int b): l(a), r(b), sum(0) {
		if (l != r) {
			left = new node(l, (l + r) / 2);
			right = new node((l + r) / 2 + 1, r);
		}
	}

	void add(int pos, int val) {
		if (l == r) sum += val;
		else if (pos <= (l + r) / 2) left->add(pos, val);
		else right->add(pos, val);

		if (l != r) sum = left->sum + right->sum;
	}

	int get(int a, int b) {
		if (r < a or b < l) return 0;
		if (a <= l and r <= b) return sum;
		else return left->get(a, b) + right->get(a, b);
	}
};

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int N, Q;
	cin >> N >> Q;
	vi kur(N + 1);
	vi sk(N);
	vii edges(N);

	for (int i = 0; i < N; ++i)
	{
		cin >> sk[i];
		kur[sk[i]] = i;
	}

	for (int i = 0; i < N; ++i)
	{
		for (int j = 1; j * j <= sk[i]; ++j)
		{
			if (sk[i] % j != 0) continue;

			if (j * j == sk[i]) {
				int pos = kur[j];
				edges[min(i, pos)].push_back(max(i, pos));
			} else {
				for (int num : {sk[i] / j, j}) {
					int pos = kur[num];
					edges[min(i, pos)].push_back(max(i, pos));
				}
			}
		}
	}

	int a, b;
	vector<query> queries(Q);
	for (int i = 0; i < Q; ++i)
	{
		cin >> a >> b; a--; b--;
		queries[i] = {a, b, i};
	}

	sort(queries.begin(), queries.end(), [](const query & pir, const query & ant) {
		return pir.l < ant.l or (pir.l == ant.l and pir.r < ant.r);
	});

	node medis(0, N - 1);

	for (int i = N - 1; i >= queries[0].l; --i)
	{
		for (auto u : edges[i])
			medis.add(u, 1);
	}

	int k = queries[0].l;

	vi ats(Q);
	for (int i = 0; i < Q; ++i)
	{
		while (k < N and k < queries[i].l) {
			for (auto u : edges[k])
				medis.add(u, -1);
			k++;
		}
		ats[queries[i].ind] = medis.get(queries[i].l, queries[i].r);
	}

	for (auto u : ats)
		printf("%d\n", u);
}

/* Look for:
* special cases (n=1?)
* overflow (ll vs int?)
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* array bounds
*/


/*input
10 9
1 2 3 4 5 6 7 8 9 10
1 10
2 9
3 8
4 7
5 6
2 2
9 10
5 10
4 10
*/
#include <bits/stdc++.h>
using namespace std;
#define TEMPLATE

#ifdef TEMPLATE
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;

#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

const int MOD = 1000000007;
const ll INF = std::numeric_limits<ll>::max();
const int MX = 100101;
const ld PI = 3.14159265358979323846264338327950288419716939937510582097494L;

template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }

template<typename T>
void print(vector<T> vec, string name = "") {
	cout << name;
	for (auto u : vec)
		cout << u << ' ';
	cout << '\n';
}

#endif

struct query {
	int l, r;
	int ind;
};

struct node {
	int l, r;
	ll sum;
	node *left = NULL;
	node *right = NULL;
	node(int a, int b): l(a), r(b), sum(0) {
		if (l != r) {
			left = new node(l, (l + r) / 2);
			right = new node((l + r) / 2 + 1, r);
		}
	}

	void add(int pos, ll val) {
		if (l == r) sum += val;
		else if (pos <= (l + r) / 2) left->add(pos, val);
		else right->add(pos, val);

		if (l != r) sum = left->sum + right->sum;
	}

	ll get(int a, int b) {
		if (r < a or b < l) return 0;
		if (a <= l and r <= b) return sum;
		else return left->get(a, b) + right->get(a, b);
	}
};

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int N, Q;
	cin >> N >> Q;
	vi kur(N + 1);
	vi sk(N);
	vii edges(N);

	for (int i = 0; i < N; ++i)
	{
		cin >> sk[i];
		kur[sk[i]] = i;
	}

	for (int i = 0; i < N; ++i)
	{
		for (int j = 1; j * j <= sk[i]; ++j)
		{
			if (sk[i] % j != 0) continue;

			if (j * j == sk[i]) {
				int pos = kur[j];
				edges[min(i, pos)].push_back(max(i, pos));
			} else {
				for (int num : {sk[i] / j, j}) {
					int pos = kur[num];
					edges[min(i, pos)].push_back(max(i, pos));
				}
			}
		}
	}

	int a, b;
	vector<query> queries(Q);
	for (int i = 0; i < Q; ++i)
	{
		cin >> a >> b; a--; b--;
		queries[i] = {a, b, i};
	}

	sort(queries.begin(), queries.end(), [](const query & pir, const query & ant) {
		return pir.l < ant.l or (pir.l == ant.l and pir.r < ant.r);
	});

	node medis(0, N - 1);

	for (int i = N - 1; i >= queries[0].l; --i)
	{
		for (auto u : edges[i])
			medis.add(u, 1);
	}

	int k = queries[0].l;

	vl ats(Q);
	for (int i = 0; i < Q; ++i)
	{
		while (k < N and k < queries[i].l) {
			for (auto u : edges[k])
				medis.add(u, -1);
			k++;
		}
		ats[queries[i].ind] = medis.get(queries[i].l, queries[i].r);
	}

	for (auto u : ats)
		printf("%lld\n", u);
}

/* Look for:
* special cases (n=1?)
* overflow (ll vs int?)
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* array bounds
*/


#include<bits/stdc++.h>
#define ll long long
#define N 300005
using namespace std;
int n,po[N],tot;ll x1,x2;
struct info{
  int x,id;
  bool operator<(const info &p)const{return x<p.x;}
}s[N];

ll cal(int x,int len)
{
  return (ll)(n-x+1-len)*s[x].x;
}

int qry(int l,int r,int tmp)
{
  while(r-l>1)
  {
    int len=(r-l+1)/3;
    int lx=l+len,rx=r-len;
    if(cal(lx,tmp)<cal(rx,tmp))l=lx;
    else r=rx;
  }
  if(cal(l,tmp)>cal(r,tmp))return l;
  return r;
}

int main()
{
  int x,num,pos,p1,p2,p;ll v1,v2;
  scanf("%d%lld%lld",&n,&x1,&x2);
  for(int i=1;i<=n;i++)
    scanf("%d",&x),s[i]=(info){x,i};
  sort(s+1,s+n+1);
  for(int i=1;i<=n;i++)
  {
    num=x1/i;if(x1%i)num++;
    pos=lower_bound(s+1,s+n+1,(info){num,0})-s;
    while(pos<=n&&s[pos].x<num)pos++;
    if(pos+i-1>n)continue;
    p1=qry(1,pos-1,i);p2=qry(pos+i,n,0);
	v1=(n-p1-i+1)*s[p1].x;v2=(n-p2+1)*s[p2].x;
	if(max(v1,v2)<x2)continue;

	tot=0;p=v1>v2?p1:p2;
	for(int j=n;j>=pos+1&&j>=p;j--)po[++tot]=j;
	for(int j=pos-1;j>=p;j--)po[++tot]=j;

	printf("Yes\n");
    printf("%d %d\n",i,tot);
    for(int j=pos;j<pos+i;j++)printf("%d ",s[j].id);
    printf("\n");
    for(int j=1;j<=tot;j++)printf("%d ",s[po[j]].id);
    printf("\n");
    return 0;
  }
  printf("No\n");
  return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define N 300005
using namespace std;
int n,po[N],tot;ll x1,x2;
struct info{
  int x,id;
  bool operator<(const info &p)const{return x<p.x;}
}s[N];

ll cal(int x,int len)
{
  return (ll)(n-x+1-len)*s[x].x;
}

int qry(int l,int r,int tmp)
{
  if(l>r)return 0;
  while(r-l>1)
  {
    int len=(r-l+1)/3;
    int lx=l+len,rx=r-len;
    if(cal(lx,tmp)<cal(rx,tmp))l=lx;
    else r=rx;
  }
  if(cal(l,tmp)>cal(r,tmp))return l;
  return r;
}

int main()
{
  int x,num,pos,p1,p2,p;ll v1,v2;
  scanf("%d%lld%lld",&n,&x1,&x2);
  for(int i=1;i<=n;i++)
    scanf("%d",&x),s[i]=(info){x,i};
  sort(s+1,s+n+1);
  for(int i=1;i<=n;i++)
  {
    num=x1/i;if(x1%i)num++;
    pos=lower_bound(s+1,s+n+1,(info){num,0})-s;
    while(pos<=n&&s[pos].x<num)pos++;
    if(pos+i-1>n)continue;
    p1=qry(1,pos-1,i);p2=qry(pos+i,n,0);
	v1=p1?(n-p1-i+1)*s[p1].x:0;
	v2=p2?v2=(n-p2+1)*s[p2].x:0;
	if(max(v1,v2)<x2)continue;
	tot=0;p=v1>v2?p1:p2;
	for(int j=n;j>=pos+i&&j>=p;j--)po[++tot]=j;
	for(int j=pos-1;j>=p;j--)po[++tot]=j;
	printf("Yes\n");
    printf("%d %d\n",i,tot);
    for(int j=pos;j<pos+i;j++)printf("%d ",s[j].id);
    printf("\n");
    for(int j=1;j<=tot;j++)printf("%d ",s[po[j]].id);
    printf("\n");
    return 0;
  }
  printf("No\n");
  return 0;
}


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

//defines
#define openin freopen("input.txt","r",stdin)
#define openout freopen("output.txt","w",stdout)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define int long long
#define mod 1000000007
#define repr(i,x,y) for (__typeof(x) i=x;i>=y;i--)
#define rep(i,x,y) for (__typeof(x) i=x;i<=y;i++)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

/* Print pair */
template <typename T,typename S>
ostream & operator << (ostream &os , const pair<T,S> &v) {
    os << "(" ;
    os << v.first << "," << v.second << ")" ;
    return os ;
}
/* Print vector */
template <typename T>
ostream & operator << (ostream &os , const vector<T> &v) {
    os << "[" ;
    int sz = v.size() ;
    for(int i = 0 ; i < sz ; ++i) {
        os << v[i] ;
        if(i!=sz-1)os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print set */
template <typename T>
ostream & operator << (ostream &os , const set<T> &v) {
    T last = *v.rbegin() ;
    os << "[" ;
    for(auto it : v) {
        os << it  ;
        if(it != last) os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print Map */
template <typename T,typename S>
ostream & operator << (ostream &os , const map<T,S> &v) {
    for(auto it : v) {
        os << it.first << " : " << it.second << "\n" ;
    }
    return os ;
}
int power(int a , int b)
{
    int res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % mod ;
        }
        b/=2 ;
        a = (a*a) % mod ;
    }
    return res ;
}

//debug
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const int N = 3e5 + 5 ;
pair<int,int> c[N] ;

bool solve(int n , int x1 , int x2 , bool rev) {
    int k2 = -1 ;
    for(int i = 1 ; i <= n ; ++i) {
        int p2 = (x2 + i - 1)/i ;
        if(c[n-i].first >= p2) {
            k2 = i ; break ;
        }
    }
    if(k2 == -1) return false ;
    int idx = 0 ;
    for(int k1 = n-k2 ; k1 >= 1 ; --k1) {
        int p1 = (x1 + k1 - 1)/k1 ;
        if(c[idx].first >= p1) {
            vector<int> ans1 , ans2 ;
            for(int k = idx ; k < idx + k1 ; ++k) {
                ans1.push_back(c[k].ss) ;
            }
            for(int k = n-k2 ; k < n ; ++k) {
                ans2.push_back(c[k].ss) ;
            }
            if(rev) swap(ans1,ans2) ;
            cout << "Yes\n" ;
            cout << ans1.size() << " " << ans2.size() << "\n" ;
            for(auto it : ans1) {
                 cout << it << " " ;
            }
            cout << endl ;
            for(auto it : ans2) {
                cout << it << " " ;
            }
            cout << endl ; return true ;
        }
        ++idx ;
    }
    return false ;
}
int32_t main()
{
    int n , x1 , x2 ;
    scanf("%lld %lld %lld",&n , &x1 , &x2) ;
    for(int i = 0 ; i < n ; ++i) {
        scanf("%lld",&c[i].ff) ;
        c[i].ss = i + 1 ;
    }
    sort(c,c+n) ;
    if(solve(n,x1,x2,0) || solve(n,x2,x1,1)) {
        return 0 ;
    }
    cout << "No\n" ;
    return 0;
}


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

//defines
#define openin freopen("input.txt","r",stdin)
#define openout freopen("output.txt","w",stdout)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define int long long
#define mod 1000000007
#define repr(i,x,y) for (__typeof(x) i=x;i>=y;i--)
#define rep(i,x,y) for (__typeof(x) i=x;i<=y;i++)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

/* Print pair */
template <typename T,typename S>
ostream & operator << (ostream &os , const pair<T,S> &v) {
    os << "(" ;
    os << v.first << "," << v.second << ")" ;
    return os ;
}
/* Print vector */
template <typename T>
ostream & operator << (ostream &os , const vector<T> &v) {
    os << "[" ;
    int sz = v.size() ;
    for(int i = 0 ; i < sz ; ++i) {
        os << v[i] ;
        if(i!=sz-1)os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print set */
template <typename T>
ostream & operator << (ostream &os , const set<T> &v) {
    T last = *v.rbegin() ;
    os << "[" ;
    for(auto it : v) {
        os << it  ;
        if(it != last) os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print Map */
template <typename T,typename S>
ostream & operator << (ostream &os , const map<T,S> &v) {
    for(auto it : v) {
        os << it.first << " : " << it.second << "\n" ;
    }
    return os ;
}
int power(int a , int b)
{
    int res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % mod ;
        }
        b/=2 ;
        a = (a*a) % mod ;
    }
    return res ;
}

//debug
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const int N = 3e5 + 5 ;
pair<int,int> c[N] ;

bool solve(int n , int x1 , int x2 , bool rev) {
    int k2 = -1 ;
    for(int i = 1 ; i <= n ; ++i) {
        int p2 = (x2 + i - 1)/i ;
        if(c[n-i].first >= p2) {
            k2 = i ; break ;
        }
    }
    if(k2 == -1) return false ;
    int idx = 0 ;
    for(int k1 = n-k2 ; k1 >= 1 ; --k1) {
        int p1 = (x1 + k1 - 1)/k1 ;
        if(c[idx].first >= p1) {
            vector<int> ans1 , ans2 ;
            for(int k = idx ; k < idx + k1 ; ++k) {
                ans1.push_back(c[k].ss) ;
            }
            for(int k = n-k2 ; k < n ; ++k) {
                ans2.push_back(c[k].ss) ;
            }
            if(rev) swap(ans1,ans2) ;
            printf("Yes\n%d %d\n",ans1.size(),ans2.size()) ;
            for(auto it : ans1) {
                printf("%lld ",it) ;
            }
            printf("\n") ;
            for(auto it : ans2) {
                printf("%lld ",it) ;
            }
            printf("\n"); return true ;
        }
        ++idx ;
    }
    return false ;
}
int32_t main()
{
    int n , x1 , x2 ;
    scanf("%lld %lld %lld",&n , &x1 , &x2) ;
    for(int i = 0 ; i < n ; ++i) {
        scanf("%lld",&c[i].ff) ;
        c[i].ss = i + 1 ;
    }
    sort(c,c+n) ;
    if(solve(n,x1,x2,0) || solve(n,x2,x1,1)) {
        return 0 ;
    }
    cout << "No\n" ;
    return 0;
}


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

//defines
#define openin freopen("input.txt","r",stdin)
#define openout freopen("output.txt","w",stdout)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define int long long
#define mod 1000000007
#define repr(i,x,y) for (__typeof(x) i=x;i>=y;i--)
#define rep(i,x,y) for (__typeof(x) i=x;i<=y;i++)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

/* Print pair */
template <typename T,typename S>
ostream & operator << (ostream &os , const pair<T,S> &v) {
    os << "(" ;
    os << v.first << "," << v.second << ")" ;
    return os ;
}
/* Print vector */
template <typename T>
ostream & operator << (ostream &os , const vector<T> &v) {
    os << "[" ;
    int sz = v.size() ;
    for(int i = 0 ; i < sz ; ++i) {
        os << v[i] ;
        if(i!=sz-1)os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print set */
template <typename T>
ostream & operator << (ostream &os , const set<T> &v) {
    T last = *v.rbegin() ;
    os << "[" ;
    for(auto it : v) {
        os << it  ;
        if(it != last) os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print Map */
template <typename T,typename S>
ostream & operator << (ostream &os , const map<T,S> &v) {
    for(auto it : v) {
        os << it.first << " : " << it.second << "\n" ;
    }
    return os ;
}
int power(int a , int b)
{
    int res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % mod ;
        }
        b/=2 ;
        a = (a*a) % mod ;
    }
    return res ;
}

//debug
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const int N = 3e5 + 5 ;
pair<int,int> c[N] ;

bool solve(int n , int x1 , int x2 , bool rev) {
    int k2 = -1 ;
    for(int i = 1 ; i <= n ; ++i) {
        int p2 = (x2 + i - 1)/i ;
        if(c[n-i].first >= p2) {
            k2 = i ; break ;
        }
    }
    if(k2 == -1) return false ;
    int idx = 0 ;
    for(int k1 = n-k2 ; k1 >= 1 ; --k1) {
        int p1 = (x1 + k1 - 1)/k1 ;
        if(c[idx].first >= p1) {
            vector<int> ans1 , ans2 ;
            for(int k = idx ; k < idx + k1 ; ++k) {
                ans1.push_back(c[k].ss) ;
            }
            for(int k = n-k2 ; k < n ; ++k) {
                ans2.push_back(c[k].ss) ;
            }
            if(rev) swap(ans1,ans2) ;
            cout << "Yes\n" ;
            cout << ans1.size() << " " << ans2.size() << "\n" ;
            for(auto it : ans1) {
                 cout << it << " " ;
            }
            cout << endl ;
            for(auto it : ans2) {
                cout << it << " " ;
            }
            cout << endl ; return true ;
        }
        ++idx ;
    }
    return false ;
}
int32_t main()
{
    fast;
    int n , x1 , x2 ;
    cin >> n >> x1 >> x2 ;
    for(int i = 0 ; i < n ; ++i) {
        cin >> c[i].ff ; c[i].ss = i + 1 ;
    }
    sort(c,c+n) ;
    if(solve(n,x1,x2,0) || solve(n,x2,x1,1)) {
        return 0 ;
    }
    cout << "No\n" ;
    return 0;
}


#include<complex>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <limits>
#include <climits>
#include <time.h>
#include <cstdio>
#include <numeric>
#define LL long long
#define LD long double
#define rei(x) scanf("%d",&x)
#define reii(x,y) scanf("%d%d",&x,&y)
#define reiii(x,y,z) scanf("%d%d%d",&x,&y,&z)

#define rel(x) scanf("%I64d",&x);
#include<complex>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <limits>
#include <climits>
#include <time.h>
#include <cstdio>
#include <numeric>
#define LL long long
#define LD long double
#define rei(x) scanf("%d",&x)
#define reii(x,y) scanf("%d%d",&x,&y)
#define reiii(x,y,z) scanf("%d%d%d",&x,&y,&z)

#define rel(x) scanf("%I64d",&x);

#define ref(x) scanf("%lf",&x)
#define rec(x) scanf("%c",&x)
#define res(x) scanf("%s",x)
#define reli(x) scanf("%[^\n]s", x)
#define fi first
#define se second
#define pb push_back
#define f(i, a, b) for(int i = a; i <= b; i++)
#define ms(Arr) memset(Arr,0,sizeof(Arr));
#define CLR(arr,val)  memset(arr,val,sizeof(arr))
#define bit(a , b) (((a)>>(b))&1)
#define fin freopen("in.txt","r",stdin)
#define fout freopen("out.txt","w",stdout)
#define fout1 freopen("out1.txt","w",stdout)
#define ftest freopen("in.txt","w",stdout)
#define lson (id << 1)
#define rson (id << 1 | 1)
#define ls (i << 1)
#define rs (i << 1 | 1)
using namespace std;
const int INF = 0x3f3f3f3f;
const LL mod = 1000000007;
const double e = 2.718281828459;
typedef pair<int, int> Pii;
typedef pair<LL, LL> Pll;

LL gcd(LL a, LL b)
{
	if (!b)return a;
	return gcd(b, a%b);
}

LL gcd1(int a, int b)
{
	if (!b)return a;
	return gcd(b, a%b);
}

LL pow_mod(LL a, LL b, LL c)
{
	LL ans = 1;
	a = a % c;
	while (b > 0)
	{
		if (b % 2 == 1)
			ans = (ans * a) % c;
		b = b / 2;
		a = (a * a) % c;
	}
	return ans;
}

int pow_int(int a, int b)
{
	int ans = 1;
	while (b > 0)
	{
		if (b % 2 == 1)
			ans = ans * a;
		b = b / 2;
		a = a * a;
	}
	return ans;
}

LL pow_llong(LL a, LL b)
{
	LL ans = 1;
	while (b > 0)
	{
		if (b % 2 == 1)
			ans = ans * a;
		b = b / 2;
		a = a * a;
	}
	return ans;
}

const int dx[9] = { 0, 1, 1, 1, 0,-1,-1,-1, 0 };
const int dy[9] = { 0, 1, 0,-1,-1,-1, 0, 1, 1 };

int Scan()
{
	int res = 0, flag = 0;
	char ch;
	if ((ch = getchar()) == '-')
	{
		flag = 1;
	}
	else if (ch >= '0' && ch <= '9')
	{
		res = ch - '0';
	}
	while ((ch = getchar()) >= '0' && ch <= '9')
	{
		res = res * 10 + (ch - '0');
	}
	return flag ? -res : res;
}

void Out(int a)
{
	if (a < 0)
	{
		putchar('-');
		a = -a;
	}
	if (a >= 10)
	{
		Out(a / 10);
	}
	putchar(a % 10 + '0');
}

LL jc_mod(LL a, LL b, LL mod)
{
	LL ans = 1;
	b = max(b, a - b);
	for (LL i = a; i > b; i--)
	{
		ans *= i;
		ans %= mod;
	}
	return ans;
}

double lg(double a)
{
	return (log(a) / log(10.0));
}

int lowbit(int x)
{
	return x & -x;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//long long：-9223372036854775808~9223372036854775807
//int：-2147483648~2147483647
//double：-1.7*10^-308~1.7*10^308，15~16位有效数字
//long double：-1.2*10^-4932~1.2*10^4932，18~19位有效数字
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

inline int read()
{
	int f = 1, x = 0; char ch = getchar();
	while (ch<'0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
	while (ch >= '0'&&ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x*f;
}

/*******************************************************
自定义结构体排序
struct Struct_Name
{
int variable;
bool operator <(const Struct_Name &other)const   //升序排序
{
return variable > other.variable;
}
};
*******************************************************/

//离散化///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//离散化///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//离散化///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define MAXNN 100010
void lisan(int *x, int n) {
	//首先c++调用一个数组直接打这个数组的类型就好了。
	int data[MAXNN];
	f(i, 1, n)data[i] = x[i];
	sort(data + 1, data + 1 + n);//排序是肯定要的。
	int o = unique(data + 1, data + 1 + n) - data - 1;//给data数组[1..n]去重，黑科技
	f(i, 1, n)x[i] = lower_bound(data + 1, data + 1 + o, x[i]) - data;//找到x[i]在data中的位置再赋值为这个位置，如果不-data就是返回这个值。
}
////////////////////////////////////////////////////end/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////end/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////end/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////三分框架 左闭右开////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////三分框架 左闭右开////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////三分框架 左闭右开////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
LL calc(int M)
{
	return 1;
}
int sanfen(int L, int R)
{
	int M, RM;
	while (L + 1 < R)
	{
		M = (L + R) / 2;
		RM = (M + R) / 2;
		if (calc(M) < calc(RM)) //计算最小值,若为最大值则>
			R = RM;
		else
			L = M;
	}
	return L;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int CaculateWeekDay(int y, int m, int d)
{
	if (m == 1 || m == 2) {
		m += 12;
		y--;
	}
	int iWeek = (d + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400) % 7;
	return iWeek;
}

////////////////////////////////////////////////////e nd/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////end/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////end/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

pair<LL,int> a[300100];

int main()
{
	int n;
	LL x1, x2;
	rei(n);
	rel(x1);
	rel(x2);
	f(i, 1, n)
	{
		rel(a[i].first);
		a[i].second = i;
	}
	sort(a + 1, a + 1 + n);

	for (int i = 1; i <= n; i++)
	{
		double t = x1 * 1.0 / i;
		if (t > a[n].first)
			continue;
		int l = 1, r = n;
		while (r > l)
		{
			int mid = (l + r) >> 1;
			if (a[mid].first >= t)
				r = mid;
			else
				l = mid + 1;
		}
		int pos = l;
		if (pos + i - 1> n)
			continue;
		if ((n-pos-i+1) && (a[pos + i].first >= x2 / (n - pos - i + 1)))
		{
			printf("Yes\n");
			printf("%d %d\n", i, (n - pos - i + 1));
			f(j, pos, pos + i - 1)
			{
				printf("%d ", a[j].second);
			}
			printf("\n");
			f(j, pos + i, n)
			{
				printf("%d ", a[j].second);
			}
			printf("\n");
			return 0;
		}
	}

	LL t = x1;
	x1 = x2;
	x2 = t;
	for (int i = 1; i <= n; i++)
	{
		double t = x1 * 1.0 / i;
		if (t > a[n].first)
			continue;
		int l = 1, r = n;
		while (r > l)
		{
			int mid = (l + r) >> 1;
			if (a[mid].first >= t)
				r = mid;
			else
				l = mid + 1;
		}
		int pos = l;
		if (pos + i - 1> n)
			continue;
		if ((n - pos - i + 1) && (a[pos + i].first >= x2 / (n - pos - i + 1)))
		{
			printf("Yes\n");
			printf("%d %d\n",  (n - pos - i + 1), i);
			f(j, pos + i, n)
			{
				printf("%d ", a[j].second);
			}
			printf("\n");
			f(j, pos, pos + i - 1)
			{
				printf("%d ", a[j].second);
			}
			printf("\n");
			return 0;
		}
	}
	printf("No\n");

	return 0;
}