#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int N = 2 * 1e6 + 10;
ll res;
ll a[N];
ll b[N];
void solve() {
  ll n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> res;
    a[i] = a[i - 1] + res;
  }
  ll q;
  cin >> q;
  while (q--) {
    ll x, y;
    cin >> x >> y;
    cout << (a[y] - a[x - 1]) / 10 << "\n";
  }
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  while (t--) {
    solve();
  }
}
