#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
using namespace std;

typedef pair<int, int> P;

int ans[110];
P seat[20];
queue<int> waiting;
int Cnt = 0;

void outputSeat(){
  for(int i = 0 ; i < 17 ; i++){
    printf("%3d ", seat[i].first);
  }
  cout << endl;
  
  for(int i = 0 ; i < 17 ; i++){
    printf("%3d ", seat[i].second);
  }
  cout << endl << endl;
}

bool come(int n, int t){
  int group = n % 5 == 1 ? 5 : 2;
  int cnt = 0, s = 0;
  bool f = false;
  for(int i = 0 ; i < 17 ; i++){
    if(seat[i].first == -1 && !f){
      s = i;
      f = true;
    }
    
    if(seat[i].first == -1){
      cnt++;
    }
    
    else cnt = 0, s = i+1, f = false;
  
    if(cnt == group){
      //cout << "OK"<<endl;
      for(int j = s ; j < s+group ; j++){
	seat[j].first = n;
	seat[j].second = 17*(n%2) + 3*(n%3) + 19 + t;
      }
      return true;
    }
  }
  return false;
}
  
void off(int n){
  for(int i = 0 ; i < 17 ; i++){
    if(seat[i].first == n) seat[i].first = -1, seat[i].second = -1;
  }
}

void solve(){
  for(int t = 0 ; t <= 610 ; t++){
    //outputSeat();
    //cout << "time = " << t << endl;
    for(int i = 0 ; i < 17 ; i++){
      if(seat[i].second == t){
	off(seat[i].first);
	if(waiting.size() > 0){
	  int num = waiting.front();
	  while(1){
	    bool f = come(num, t);
	    if(f){
	      ans[num] = t - ans[num];
	      waiting.pop();
	      num = waiting.front();
	      if(num == 0) break;
	    }
	    else break;
	  }
	}
      }
    }
    
    //cout << "front = " << waiting.front() << endl;
    
    if(t % 5 == 0 && Cnt < 100){
      Cnt++;
      int number = t / 5;
      if(waiting.size() > 0){
	ans[number] = t;
	waiting.push(number);
	continue;
      }
      bool f = come(number, t);
      if(f) ans[number] = 0;
      else{
	waiting.push(number);
	ans[number] = t;
      }
    }    
    
  }
  
}

void init(){
  memset(seat, -1 , sizeof(seat));  
  memset(ans, 0, sizeof(ans));
}

int main(){
  init();
  solve();
  int n;

  while(cin >> n) cout << ans[n] << endl;
  return 0;
}