def dist(a, b, c)
  (a + c - b) % a < (a + b - c) % a ? (a + c - b) % a : (a + b - c) % a
end

n, m, p = gets.split.map(&:to_i)
d = []
count = 0
e = nil

while count < m
  d << gets.to_i
  count += 1
end

d.permutation(d.size) do |i|
  f = 0
  g = p
  i.each do |j|
    f += dist(n, j, g)
    g = j
  end
  e = f if e.nil? || e > f
end

puts e * 100