def setsubun(k, n, family) require_beans = family.sum remain = k * n - require_beans (remain >= 0) ? remain : -1 end k, n, f = gets.split.map(&:to_i) family = gets.split.map(&:to_i) p setsubun(k, n, family)