loop {
    d = gets.to_i
    break if d == 0
    n = gets.to_i
    m = gets.to_i

    shop = [0] + (2..n).map{ gets.to_i }.sort + [d]

    dist = Array.new(d+1)
    shop.each_cons(2){|x, y|
        (0..(y-x)/2).each{|i|
            dist[x+i] = i
            dist[y-i] = i
        }
    }

    p (1..m).inject(0){|s, _| s + dist[gets.to_i] }
}