#include // https://github.com/SkyLake-git/CompeteLib template concept Arithmetic = std::is_arithmetic_v; template concept FloatingPoint = std::is_floating_point_v; template concept GraphLike = requires(T &a) { { a.get_next() } -> std::convertible_to>; a.get_next(std::declval()); }; template concept GridLike = requires(T &a) { { a[std::declval()] }; sizeof(a); }; enum DistanceAlgo { Euclidean, Manhattan }; template concept DataContainer = requires { typename T::value_type; } && (std::is_same_v> || std::is_same_v> || std::is_same_v>); template void push_to_data_container(T &container, typename T::value_type v) { container.push(v); } template T::value_type peek_from_data_container(T &container) { if constexpr (std::is_same_v>) { return container.front(); } else if constexpr (std::is_same_v>) { return container.top(); } else if constexpr (std::is_same_v>) { return container.top(); } throw std::runtime_error("unexpected type of data container"); } template void pop_from_data_container(T &container) { container.pop(); } template T factorial(T a) { T res = 1; for (T i = a; i > 0; --i) { res *= i; } return res; } template T factorial_mod(T a, T mod) { T res = 1; for (T i = a; i > 0; --i) { res *= i; res %= mod; } return res; } template T probability(T a, T c) { T res = a; for (int i = 0; i < c; ++i) { res *= a - i; } return res; } // 繰り返し2乗法 template R pow_int(T a, T exponent) { R x = 1; while (exponent > 0) { if (exponent % 2 == 1) { x *= a; } a *= a; exponent >>= 1; } return x; } template T ceil_div(T a, T b) { if (b < 0) a *= -1, b *= -1; if (a <= 0) return a / b; return (a - 1) / b + 1; } template bool is_inside_bounds(T x, T y, T width, T height) { return x >= 0 && y >= 0 && x < width && y < height; } inline long long ceil_ll(const long double a) { return static_cast(std::ceill(a)); } inline long long floor_ll(const long double a) { return static_cast(std::floorl(a)); } template struct triplet { T1 first{}; T2 second{}; T3 third{}; triplet() = default; triplet(T1 first, T2 second, T3 third) { this->first = first; this->second = second; this->third = third; } auto operator<=>(const triplet &) const = default; struct less_second { bool operator()(triplet &a, triplet &b) { return a.second < b.second; } }; struct greater_second { bool operator()(triplet &a, triplet &b) { return a.second > b.second; } }; struct less_third { bool operator()(triplet &a, triplet &b) { return a.third < b.third; } }; struct greater_third { bool operator()(triplet &a, triplet &b) { return a.third > b.third; } }; }; template struct quadruplet { T1 first{}; T2 second{}; T3 third{}; T4 fourth{}; quadruplet() = default; quadruplet(T1 first, T2 second, T3 third, T4 fourth) { this->first = first; this->second = second; this->third = third; this->fourth = fourth; } auto operator<=>(const quadruplet &) const = default; }; template void debug_arr(auto arr, const T size) { } static std::mt19937_64 rnd_mt64(100); namespace timer { static std::chrono::time_point start_time = std::chrono::steady_clock::now(); inline long long elapsed_ms() { return std::chrono::duration_cast(std::chrono::steady_clock::now() - start_time). count(); } inline void reset() { start_time = std::chrono::steady_clock::now(); } } inline unsigned long long randl_range(unsigned long long min_val, unsigned long long max_val) { std::uniform_int_distribution get_rand_uni_int(min_val, max_val); return get_rand_uni_int(rnd_mt64); } inline unsigned int randi_range(unsigned int min_val, unsigned int max_val) { std::uniform_int_distribution get_rand_uni_int(min_val, max_val); return get_rand_uni_int(rnd_mt64); } inline long double randf() { return static_cast(randl_range(0, std::numeric_limits::max())) / std::numeric_limits::max(); } inline std::generator range_bfs(int min, int max, int start) { co_yield start; for (int d = 1; d <= max - min; ++d) { int right = start + d; int left = start - d; if (right <= max) co_yield right; if (left >= min) co_yield left; } } // (min + max) / 2 から1ずつmin, maxに近づいていく数列を返す inline std::generator range_mid_bfs(int min, int max) { return range_bfs(min, max, (min + max) / 2); } template std::ostream &operator<<(std::ostream &os, std::vector arr) { std::string s = "[ "; for (int i = 0; i < arr.size(); ++i) { s.append(std::to_string(arr[i]) + ", "); } os << s << "]"; return os; } inline void hack_syncio() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); } using ll = long long; using ull = unsigned long long; using ld = long double; using namespace std; int main() { hack_syncio(); int dur = 6000; int t[7]; for (int i = 0; i < 7; ++i) { cin >> t[i]; } for (int i = 0; i < 7; ++i) { int sum = 0; for (int j = 0; j <= i; ++j) { if (t[j] == -1) { sum += dur; } else { sum += t[j]; } } int unnecessary_osyaberi_time = dur - sum; if (unnecessary_osyaberi_time <= 0) { cout << -1 << "\n"; } else { cout << unnecessary_osyaberi_time << "\n"; } } }