#!/bin/bash
read N
for i in $(seq 1 $N); do
  line="${line} T${i}"
done
read $line
read M
declare -a P=()
declare -a X=()
for i in $(seq 1 $M); do
  read p x
  P+=($p)
  X+=($x)
done

num=0
sum=0

for i in $(seq 1 $N); do
  num=$((num + T$i))
done

for i in $(seq 0 $((M-1))); do
  echo $(( num + ${X[$i]} - T${P[$i]}))
done
