A new innovative ticketing systems for public transport is introduced in Bytesburg. Now there is a single travel card for all transport. To make a trip a passenger scan his card and then he is charged according to the fare.

The fare is constructed in the following manner. There are three types of tickets:   a ticket for one trip costs 20 byteland rubles,  a ticket for 90 minutes costs 50 byteland rubles,  a ticket for one day (1440 minutes) costs 120 byteland rubles. 

Note that a ticket for x minutes activated at time t can be used for trips started in time range from t to t + x - 1, inclusive. Assume that all trips take exactly one minute.

To simplify the choice for the passenger, the system automatically chooses the optimal tickets. After each trip starts, the system analyses all the previous trips and the current trip and chooses a set of tickets for these trips with a minimum total cost. Let the minimum total cost of tickets to cover all trips from the first to the current is a, and the total sum charged before is b. Then the system charges the passenger the sum a - b.

You have to write a program that, for given trips made by a passenger, calculates the sum the passenger is charged after each trip.


-----Input-----

The first line of input contains integer number n (1 ≤ n ≤ 10^5) — the number of trips made by passenger.

Each of the following n lines contains the time of trip t_{i} (0 ≤ t_{i} ≤ 10^9), measured in minutes from the time of starting the system. All t_{i} are different, given in ascending order, i. e. t_{i} + 1 > t_{i} holds for all 1 ≤ i < n.


-----Output-----

Output n integers. For each trip, print the sum the passenger is charged after it.


-----Examples-----
Input
3
10
20
30

Output
20
20
10

Input
10
13
45
46
60
103
115
126
150
256
516

Output
20
20
10
0
20
0
0
20
20
10



-----Note-----

In the first example, the system works as follows: for the first and second trips it is cheaper to pay for two one-trip tickets, so each time 20 rubles is charged, after the third trip the system understands that it would be cheaper to buy a ticket for 90 minutes. This ticket costs 50 rubles, and the passenger had already paid 40 rubles, so it is necessary to charge 10 rubles only.

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Dynamic programming

Sorting


Solutions:
a = b = 1
(p, s) = ([0, 0], [0, 0])
for i in range(int(input())):
	p.append(int(input()))
	while p[-1] - p[a] > 89:
		a += 1
	while p[-1] - p[b] > 1439:
		b += 1
	s.append(min(s[-1] + 20, s[a - 1] + 50, s[b - 1] + 120))
print(' '.join((str(u - v) for (u, v) in zip(s[2:], s[1:]))))


n = int(input())
trips = []
prix = [0]
k = 0
j = 0
for i in range(n):
	trips.append(int(input()))
	while trips[i] - trips[j] >= 90:
		j += 1
	while trips[i] - trips[k] >= 1440:
		k += 1
	prix.append(min(min(prix[k] + 120, prix[j] + 50), prix[-1] + 20))
	print(prix[-1] - prix[-2])


def go(l, key, plus):
	while t[l + 1] + plus - 1 < key:
		l += 1
	return l
INF = 10 ** 9
n = int(input())
t = [INF] * (n + 1)
t[0] = -INF
c = [0] * (n + 1)
l1 = 0
l2 = 0
for i in range(1, n + 1):
	t[i] = int(input())
	l1 = go(l1, t[i], 90)
	l2 = go(l2, t[i], 1440)
	c1 = c[i - 1] + 20
	c2 = c[l1] + 50
	c3 = c[l2] + 120
	c[i] = min(c1, c2, c3)
	print(c[i] - c[i - 1])


n = int(input())
a = [0]
for i in range(n):
	x = int(input())
	a.append(x)
dp = [0] * (n + 1)
dp[0] = 0
p90 = 1
p1440 = 1
for i in range(1, n + 1):
	dp[i] = dp[i - 1] + 20
	while a[p90] + 90 <= a[i]:
		p90 = p90 + 1
	dp[i] = min(dp[i], dp[p90 - 1] + 50)
	while a[p1440] + 1440 <= a[i]:
		p1440 = p1440 + 1
	dp[i] = min(dp[i], dp[p1440 - 1] + 120)
for i in range(1, n + 1):
	print(dp[i] - dp[i - 1])


def lower_bound(arr, left, right, target):
	if arr[right] < target:
		return right + 1
	while left < right:
		mid = left + right >> 1
		if arr[mid] >= target:
			right = mid
		else:
			left = mid + 1
	return left
T = int(input())
arr = [0] * T
dp = [0] * (T + 1)
for i in range(T):
	arr[i] = int(input())
for i in range(T):
	dp[i + 1] = dp[i] + 20
	dp[i + 1] = min(dp[i + 1], dp[lower_bound(arr, 0, T - 1, arr[i] - 89)] + 50)
	dp[i + 1] = min(dp[i + 1], dp[lower_bound(arr, 0, T - 1, arr[i] - 1439)] + 120)
	print(dp[i + 1] - dp[i])


n = int(input())
time = []
for i in range(n):
	time.append(int(input()))
ptr90 = 0
ptrs = 0
dp = [0] * n
dp[0] = 20
print(20)
for i in range(1, n):
	s1 = dp[i - 1] + 20
	if time[i] <= 89 + time[ptr90]:
		if ptr90 == 0:
			s2 = 50
		else:
			s2 = dp[ptr90 - 1] + 50
	else:
		while time[ptr90] + 89 < time[i]:
			ptr90 += 1
		s2 = dp[ptr90 - 1] + 50
	if time[i] <= 1439 + time[ptrs]:
		if ptrs == 0:
			s3 = 120
		else:
			s3 = dp[ptrs - 1] + 120
	else:
		while time[ptrs] + 1439 < time[i]:
			ptrs += 1
			s3 = dp[ptrs - 1] + 120
	dp[i] = min(s1, s2, s3)
	print(dp[i] - dp[i - 1])


n = int(input())
times = []
first_90 = 0
first_1440 = 0
sum_90 = 0
sum_1440 = 0
values = []
for i in range(n):
	times.append(int(input()))
	while times[first_90] <= times[-1] - 90:
		sum_90 -= values[first_90]
		first_90 += 1
	while times[first_1440] <= times[-1] - 1440:
		sum_1440 -= values[first_1440]
		first_1440 += 1
	values.append(min([20, 50 - sum_90, 120 - sum_1440]))
	sum_90 += values[-1]
	sum_1440 += values[-1]
print(*values, sep='\n')


n = int(input())
ex1 = 0
ex2 = 0
L = []
f = [0] * (n + 1)
for i in range(n):
	L.append(int(input()))
	while L[i] - L[ex1] >= 90:
		ex1 += 1
	while L[i] - L[ex2] >= 1440:
		ex2 += 1
	f[i + 1] = min(min(f[ex1] + 50, f[ex2] + 120), f[i] + 20)
	print(f[i + 1] - f[i])


from bisect import bisect_right
from math import inf
n = int(input())
dp = [inf] * n
dp[0] = 20
a = [int(input())]
for i in range(n - 1):
	a.append(int(input()))
print(dp[0])
for i in range(1, n):
	dp[i] = min(dp[i], dp[i - 1] + 20)
	if a[i] - a[0] >= 90:
		dp[i] = min(dp[i], dp[bisect_right(a, a[i] - 90) - 1] + 50)
	else:
		dp[i] = min(dp[i], 50)
	if a[i] - a[0] >= 1440:
		dp[i] = min(dp[i], dp[bisect_right(a, a[i] - 1440) - 1] + 120)
	else:
		dp[i] = min(dp[i], 120)
	print(dp[i] - dp[i - 1])


n = int(input())
dp = [0]
vrijeme = [0]
(x, y) = (1, 1)
for i in range(n):
	put = int(input())
	vrijeme.append(put)
	while put - vrijeme[x] > 89:
		x += 1
	while put - vrijeme[y] > 1439:
		y += 1
	sol = min(dp[-1] + 20, dp[x - 1] + 50, dp[y - 1] + 120)
	dp.append(sol)
for w in range(1, n + 1):
	print(dp[w] - dp[w - 1])


from bisect import bisect_left, bisect_right

def check(cost, time):
	if total < cost:
		return 0
	t_i = bisect_right(arr, total - cost)
	if timer[i] - timer[t_i] <= time:
		return 1
	return 0
n = int(input())
arr = [99999999] * (n + 1)
total = 0
ans = [0] * n
timer = [0] * (n + 1)
for i in range(n):
	t = int(input())
	timer[i] = t
	if check(50, 90 - 1):
		total += 0
	elif check(120, 1440 - 1):
		total += 0
	elif check(40, 90 - 1):
		total += 10
		ans[i] = 10
	elif check(110, 1440 - 1):
		total += 10
		ans[i] = 10
	else:
		total += 20
		ans[i] = 20
	arr[i] = total
for i in ans:
	print(i)


import sys
import bisect
input = sys.stdin.readline
trips = int(input())
dyn = [int(input()) for i in range(trips)]
cmap = [0, 20] + [0 for i in range(trips - 1)]
for i in range(2, trips + 1):
	cmap[i] = min(cmap[i - 1] + 20, cmap[bisect.bisect_left(dyn, dyn[i - 1] - 89)] + 50, cmap[bisect.bisect_left(dyn, dyn[i - 1] - 1439)] + 120)
for i in range(1, trips + 1):
	print(cmap[i] - cmap[i - 1])


import math
import sys
from bisect import bisect_right, bisect_left, insort_right
from collections import Counter, defaultdict
from heapq import heappop, heappush
from itertools import accumulate, permutations, combinations
from sys import stdout
R = lambda : map(int, input().split())
n = int(input())
arr = []
for _ in range(n):
	arr.append(int(input()))
cst = [math.inf] * n + [0]
for i in range(n):
	cst[i] = min(cst[i - 1] + 20, cst[bisect_left(arr, arr[i] - 89) - 1] + 50, cst[bisect_left(arr, arr[i] - 1439) - 1] + 120)
for i in range(n):
	print(cst[i] - cst[i - 1])


import sys
input = sys.stdin.readline
n = int(input())
(b1, b2) = (0, 0)
l = []
f = [0] * (n + 1)
for i in range(n):
	t = int(input())
	l.append(t)
	while l[i] - l[b1] >= 90:
		b1 += 1
	while l[i] - l[b2] >= 1440:
		b2 += 1
	f[i + 1] = min(f[b1] + 50, f[b2] + 120, f[i] + 20)
	print(f[i + 1] - f[i])


n = int(input())
t = [int(input()) for _ in range(n)]
INF = 10 ** 12
ll = [1, 90, 1440]
pp = [20, 50, 120]
lowest_price = [0] * n
p = pp[0]
lowest_price[0] = p
for i in range(1, n):
	u = lowest_price[i - 1] + pp[0]
	for j in range(1, 3):
		l = ll[j]
		p = pp[j]
		start = t[i] - l + 1
		prev = 0
		if t[0] < start:
			b = i
			a = max(0, b - l)
			while b - a > 1:
				m = (a + b) // 2
				if t[m] < start:
					a = m
				else:
					b = m
			prev = lowest_price[a]
		if prev + p < u:
			u = prev + p
	lowest_price[i] = u
to_print = [0] * n
to_print[0] = lowest_price[0]
for i in range(1, n):
	if lowest_price[i - 1] < lowest_price[i]:
		to_print[i] = lowest_price[i] - lowest_price[i - 1]
print(*to_print, sep='\n')


n = int(input())
t = [-(1 << 30)]
for i in range(n):
	t.append(int(input()))
dp = [0]
paid = 0
for i in range(1, n + 1):
	cost = 20 + dp[-1]
	j = i - 1
	while j >= 0:
		if t[i] - t[j] >= 90:
			cost = min(cost, 50 + dp[j])
			break
		j -= 1
	while j >= 0:
		if t[i] - t[j] >= 1440:
			cost = min(cost, 120 + dp[j])
			break
		j -= 1
	dp.append(cost)
	print(cost - paid)
	paid = cost


import sys

def bs(l, r, val):
	l1 = l
	r1 = r
	while l1 <= r1:
		mid = (l1 + r1) // 2
		if t[mid] >= val:
			res = mid
			r1 = mid - 1
		elif t[mid] < val:
			l1 = mid + 1
	return res
t = []
n = int(sys.stdin.readline())
for i in range(n):
	temp = int(sys.stdin.readline())
	t.append(temp)
sum = [0 for i in range(n)]
for i in range(n):
	nine_ty = bs(0, i, t[i] - 90 + 1)
	if nine_ty > 0:
		temp = min(20, max(50 - (sum[i - 1] - sum[nine_ty - 1]), 0))
	else:
		temp = min(20, 50 - sum[max(i - 1, 0)])
	a_day = bs(0, i, t[i] - 1440 + 1)
	if a_day > 0:
		temp = min(temp, max(120 - (sum[i - 1] - sum[a_day - 1]), 0))
	else:
		temp = min(temp, 120 - sum[max(i - 1, 0)])
	print(temp)
	sum[i] = sum[max(i - 1, 0)] + temp


import bisect

def getIndex(a, x):
	for i in range(0, len(a)):
		if a[i] > x:
			return i
	return 0
n = int(input())
times = []
total = 0
for i in range(0, n):
	time = int(input())
	times.append(time)
	total += time
cost = [0 for i in range(0, n + 1)]
cost[0] = 0
cost[1] = 20
for i in range(2, n + 1):
	cost[i] = min(cost[i - 1] + 20, cost[bisect.bisect_left(times, times[i - 1] - 89)] + 50, cost[bisect.bisect_left(times, times[i - 1] - 1439)] + 120)
for i in range(1, n + 1):
	print(cost[i] - cost[i - 1])


n = int(input())
travel_times = list()
travel_pay = list()
pay_ticket1 = 0
time_ticket1 = 0
pay_ticket2 = 0
time_ticket2 = 0
for travel_id in range(n):
	t = int(input())
	travel_times.append(t)
	pay2 = 20
	sum_time1 = t - travel_times[time_ticket1]
	sum_time2 = t - travel_times[time_ticket2]
	if sum_time1 >= 90:
		pay_ticket1 -= travel_pay[time_ticket1]
		for id2 in range(time_ticket1 + 1, travel_id + 1):
			if t - travel_times[id2] < 90:
				time_ticket1 = id2
				break
			else:
				pay_ticket1 -= travel_pay[id2]
		sum_time1 = t - travel_times[time_ticket1]
	if sum_time2 >= 1440:
		pay_ticket2 -= travel_pay[time_ticket2]
		for id2 in range(time_ticket2 + 1, travel_id + 1):
			if t - travel_times[id2] < 1440:
				time_ticket2 = id2
				break
			else:
				pay_ticket2 -= travel_pay[id2]
		sum_time2 = t - travel_times[time_ticket2]
	if pay_ticket1 + pay2 > 50:
		pay2 = 50 - pay_ticket1
	if pay_ticket2 + pay2 > 120:
		pay2 = 120 - pay_ticket2
	pay_ticket1 += pay2
	pay_ticket2 += pay2
	travel_pay.append(pay2)
for pay in travel_pay:
	print(pay)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop, heapify
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
from itertools import accumulate
from functools import lru_cache
M = mod = 998244353

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
n = val()
l = []
for i in range(n):
	l.append(val())
l.sort()
l1 = [0]
l2 = [-float('inf')]
for i in l:
	ind2 = br(l2, i - 90) - 1
	ind1 = br(l2, i - 1) - 1
	ind3 = br(l2, i - 1440) - 1
	l2.append(i)
	l1.append(min(l1[ind1] + 20, l1[ind2] + 50, l1[ind3] + 120))
l2[0] = 0
for i in range(1, n + 1):
	print(l1[i] - l1[i - 1])
print()


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import deque
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
n = int(input())
ex1 = 0
ex2 = 0
L = []
f = [0] * (n + 1)
for i in range(n):
	L.append(int(input()))
	while L[i] - L[ex1] >= 90:
		ex1 += 1
	while L[i] - L[ex2] >= 1440:
		ex2 += 1
	f[i + 1] = min(min(f[ex1] + 50, f[ex2] + 120), f[i] + 20)
	print(f[i + 1] - f[i])


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key, lru_cache
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip().split()]

def st():
	return str(input().rstrip())[2:-1]

def val():
	return int(input().rstrip())

def li2():
	return [str(i)[2:-1] for i in input().rstrip().split()]

def li3():
	return [int(i) for i in st()]
n = val()
l = []
for i in range(n):
	l.append(val())
l.sort()
l1 = [0]
l2 = [-float('inf')]
for i in l:
	ind2 = br(l2, i - 90) - 1
	ind1 = br(l2, i - 1) - 1
	ind3 = br(l2, i - 1440) - 1
	l2.append(i)
	l1.append(min(l1[ind1] + 20, l1[ind2] + 50, l1[ind3] + 120))
l2[0] = 0
for i in range(1, n + 1):
	print(l1[i] - l1[i - 1])
print()


def main():
	N = int(input())
	S = [0]
	T = [0]
	kh = 0
	kd = 0
	for n in range(1, N + 1):
		T.append(int(input()))
		for i in range(kh + 1, n):
			if T[n] - T[i] < 90:
				kh = i - 1
				break
			else:
				kh = i
		for i in range(kd + 1, n):
			if T[n] - T[i] < 1440:
				kd = i - 1
				break
			else:
				kd = i
		S.append(min(20 + S[n - 1], 50 + S[kh], 120 + S[kd]))
		print(S[n] - S[n - 1])
main()


n = int(input())
dp = [0]
t = [0]
(i, j) = (1, 1)
for _ in range(n):
	x = int(input())
	t.append(x)
	while x - t[i] > 89:
		i += 1
	while x - t[j] > 1439:
		j += 1
	try:
		y = min(dp[-1] + 20, dp[i - 1] + 50, dp[j - 1] + 120)
		dp.append(y)
	except:
		print(i, j)
ans = []
for i in range(n):
	ans.append(dp[i + 1] - dp[i])
print(*ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
import bisect
from collections import Counter
import bisect
n = int(input())
trips = []
p = [0]
k = 0
j = 0
for i in range(n):
	trips.append(int(input()))
	while trips[i] - trips[j] >= 90:
		j += 1
	while trips[i] - trips[k] >= 1440:
		k += 1
	p.append(min(min(p[k] + 120, p[j] + 50), p[-1] + 20))
	print(p[-1] - p[-2])