fn main() {
    let (n, a, t) = read();
    let ans = solve(n, a, t);
    //write(ans);
}
 
fn read() -> (i32, Vec<i32>, Vec<(i32, i32)>) {
    let mut l1 = String::new();
    std::io::stdin().read_line(&mut l1).ok();
    let n: i32 = l1.trim().parse().unwrap();
 
 
    let mut l1 = String::new();
    std::io::stdin().read_line(&mut l1).ok();
    let iter = l1.trim().split_whitespace();
    let mut a: Vec<i32> = Vec::new();
    for i in iter {
        a.push(i.parse().unwrap());
    }
 
    let mut l1 = String::new();
    std::io::stdin().read_line(&mut l1).ok();
    let q: i32 = l1.trim().parse().unwrap();
 
    let mut t: Vec<(i32, i32)> = Vec::new();
    for i in 0..q {
        let mut l1 = String::new();
        std::io::stdin().read_line(&mut l1).ok();
        let mut iter = l1.trim().split_whitespace();
        let b: i32 = iter.next().unwrap().parse().unwrap();
        let c: i32 = iter.next().unwrap().parse().unwrap();
 
        t.push((b, c));
    }
 
    (n, a, t)
}
 
fn write(s: i32) {
    println!("{}", s);
}
 
fn solve(n: i32, mut a: Vec<i32>, t: Vec<(i32, i32)>) {
    for (i, j) in t.iter() {
        let s: i32 = a.iter().map(|&x| if x == *i {*j} else {x}).sum();
        println!("{}", s);
    }
}