#include <bits/stdc++.h>
using namespace std;
const int k = sqrt(1e5)+1;
int ve[k], arr[(int)1e5], n, sz;

void build()
{
    sz = sqrt(n);
    int idx = -1;
    for (int i = 0; i < n; i++)
    {
        if (i%sz == 0)
            ve[++idx] = arr[i];
        ve[idx] = min(ve[idx], arr[i]);
    }
}

int querry(int l, int r)
{
    int val = 2147483647;
    while (l%sz != 0 && l <= r)
        val = min(arr[l++], val);
    while (r-l >= sz)
    {
        val = min(val, ve[l/sz]);
        l += sz;
    }
    while (l <= r)
        val = min(val, arr[l++]);
    return val;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    build();
    int q; cin >> q;
    while (q--)
    {
        int l, r; cin >> l >> r;
        cout << querry(l,r) << '\n';
    }
}
