// 標準入力
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(){
  // faster initialize
  var seats = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  var waitTime = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];

  var groupMembers = [2,5,2,2,2];
  var eatTimes = [19,39,25,36,22,42];
  var headGroup = -1;
  var pastMinutes = 0;
  var lastMembers = 100;
  var notWait = true;

  var i;

  
  while(lastMembers){

    // たべおわる
    for(i = 17; i--;){
      seats[i] = max(0, --seats[i]);
    }
    
    // 来店
    if(notWait && !(pastMinutes % 5)){
      headGroup = pastMinutes / 5;// %5してるから絶対に整数
    }
    
    // ちゃくせき
    while(headGroup != -1){
      var needsSequencialSeats = groupMembers[headGroup % 5];
      var sequencialSeats = 0;
      var startIndex = -1;
      for(i = 0; i < 17; i++){
        sequencialSeats = seats[i] == 0 ? ++sequencialSeats : 0;
        
        if(sequencialSeats == needsSequencialSeats){
          startIndex = i - (needsSequencialSeats - 1);
          break;
        }
      }
      
      if(startIndex != -1){
        // すわれたみたい
        waitTime[headGroup] = pastMinutes - (headGroup * 5);
        for(var i = startIndex; i < (needsSequencialSeats + startIndex); i++){
          seats[i] = eatTimes[headGroup % 6];
        }
        
        headGroup = (((headGroup + 1) * 5) <= pastMinutes) ? headGroup + 1 : -1;
        lastMembers--;
      }else{
        // すわれなかったみたい
        break;
      }
      
    }
    
    pastMinutes++;
    
  }
  
  for(var i = 0, len = input.length - 1; i < len; i++){
    console.log(waitTime[parseInt(input[i], 10)]);
  }
  
}

function max(a, b){
 var t = (a - b);
 return a - (t & (t >> 31));
}