#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
const int N = 1e5 + 20;
using namespace std;
int main() {
  int n, s[N], m;
  s[0] = 0;
  cin >> n;
  for (int i = (1); i <= (n); i++) {
    cin >> m;
    s[i] = s[i - 1] + m;
  }
  cin >> m;
  for (int i = (1); i <= (m); i++) {
    int x, y;
    cin >> x >> y;
    cout << (s[y] - s[x - 1]) / 10 << endl;
  }
  return 0;
}
