#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
  long long int n;
  cin >> n;
  long long int a[n + 5];
  for (long long int i = 1; i <= n; i++) cin >> a[i];
  long long int dp[n + 5];
  memset(dp, 0, sizeof(dp));
  long long int s = 0;
  for (long long int i = n; i >= 1; i--) {
    s = s + a[i];
    dp[i] = s;
  }
  long long int q;
  cin >> q;
  while (q--) {
    long long int l, r;
    cin >> l >> r;
    s = dp[l] - dp[r + 1];
    cout << s / 10 << "\n";
  }
}
