// converting stan73
function processData(input) {
var pass , fail ,not_app ;
var arr = input.split('\n');
var n = Number(arr[0]);
for (let i = 1; i <= n; i++) {
if (arr[i] < 40) {
fail = Number(arr[i])
console.log(fail);
}
if (arr[i] > 40 && (Math.floor(arr[i]%5) < 3) ) {
pass = Number(arr[i]) + Math.floor(arr[i - 1]%5)
console.log(pass);
}
if((Math.floor(arr[i]%5) >= 3 && arr[i] > 40 )){
not_app = Number(arr[i])
console.log(not_app);
}
}
}
process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
_input += input;
});
process.stdin.on("end", function () {
processData(_input);
});