# frozen_string_literal: true in_t = gets.chomp.split.map(&:to_i) total = 6000 in_t.each do |t| total -= t if total < 0 || t == -1 total = -1 puts -1 else puts total end end