#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long a[n + 1];
  for (long long i = 1; i <= n; i++) cin >> a[i];
  long long dp[n + 1];
  for (long long i = 1; i <= n; i++) dp[i] = a[i];
  dp[0] = 0;
  for (long long i = 1; i <= n; i++) dp[i] += dp[i - 1];
  long long t;
  cin >> t;
  while (t--) {
    long long x, y;
    cin >> x >> y;
    long long ans = (dp[y] - dp[x - 1]) / 10;
    cout << ans << "\n";
  }
}
