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.

Difficulty: interview

Starter code:

Solutions:
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])



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)

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)
    
    # print(cost[getIndex(89, times, i - 1)] + 50)
# print(cost)
# print(times)
for i in range(1, n + 1):
    print(cost[i] - cost[i - 1])


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):
			#print(T[n], T[i])
			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
		#print(n, kh, kd)
		#print(20, S[n - 1], 50, S[kh], 120, S[kd])
		S.append(min(20 + S[n - 1], 50 + S[kh], 120 + S[kd]))
		#print(T)
		#print(S)
		print(S[n] - S[n - 1])

main()

# 1509134058412


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])


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])
    


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])



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])

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])

    





# Made By Mostafa_Khaled


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])

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
    # print(ind1, ind2, ind3)
    l2.append(i)
    l1.append(min(l1[ind1] + 20, l1[ind2] + 50, l1[ind3] + 120))
    # print(l1, l2)
l2[0] = 0
# print(l2)
for i in range(1, n + 1):
    print(l1[i] - l1[i - 1])
print()


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
    # print(ind1, ind2, ind3)
    l2.append(i)
    l1.append(min(l1[ind1] + 20, l1[ind2] + 50, l1[ind3] + 120))
    # print(l1, l2)
l2[0] = 0
# print(l2)
for i in range(1, n + 1):
    print(l1[i] - l1[i - 1])
print()