#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 100010;
int n, m;
int s[2 * N];
int main()
{
cin >> n;
for (int i = 1; i <= n; i ++ ) cin >> s[i], s[i + n] = s[i];
for (int i = 1; i <= 2 * n; i ++ ) s[i] += s[i - 1];
cin >> m;
while (m -- )
{
int x, y;
cin >> x >> y;
if (x > y) swap(x, y);
cout << min(s[y - 1] - s[x - 1], s[x + n - 1] - s[y - 1]) << endl;
}
return 0;
}