var fs = require('fs'),
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
function main(){
  var groupMems = {2, 5, 2, 2, 2};
  var eatTimes = {19, 39, 25, 36, 22, 42};

  var seats = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

  var waitTimes; // 待ち時間
  var headGroup = null; // 待ちの先頭
  var pastMinutes; // 経過時間
  var sitGroup = 0; // 座ったグループ数

  while(sitGroup <= 100){
    // たべる
    for(var seatNo = 0; seatNo < 17; seatNo++){
      seats[seatNo] = seats[seatNo] == 0 ? 0 : seatNo - 1;
    }
    // らいてん
    if(headGroup === null && pastMinutes % 5 == 0){
      headGroup = Math.floor(pastMinutes / 5);
    }

    // 座る
    var sit = true;
    while(headGroup != null && sit == true){
      var needsSequencial = groupMems[headGroup % 5];
      var sequancialSeats = 0;
      var startIndex = -1;
      for(var seatNo = 0; seatNo < 17; seatNo++){
        sequencialSeats = seats[seatNo] == 0 ? sequencialSeats + 1 : 0; 
        if(sequencialSeats == needsSequencial){
          startIndex = seatNo - (needsSequencial - 1);
          break;
        }
      }

      if(startIndex != -1){
        // 座れた
       waitTimes[headGroup] = pastMinutes - (headGroup * 5);
       sit = true;
       sitGroup++;
       for(var seatNo = startIndex; seatNo < needsSequencial; seatNo++){
         seats[seatNo] = eatTimes[headGroup % 5];
       }
       if(headGroup * 5 < pastMinutes){
         // まだ客がいる
         headGroup++;
       }else{
         headGroup = null;
       }
      }else{
        // すわれなかった
        sit = false;
      }

    }

  }

  for(var i = 0; i < input.length; i++){
    console.log(waitTimes[input[i]]);
  }

}