# Arup Guha
# 4/29/2020
# Alternate Solution to 2020 FHSPS Problem: Toilet Paper

# Get # of cases.
nC = int(input(""))

# Process cases.
for loop in range(nC):

    # Get the number of rolls.
    rolls = int(input(""))

    # How much he earns (gross revenue)
    earn = min(500, 5*rolls)

    # Subtract out the cost
    print(earn - rolls)
