#include<iostream>
#include<queue>
using namespace std;

int main(){
  int t[100];
  int c[17],ans[100],time;
  queue<int> q;

  for(int i=0;i<100;i++)t[i] = 17*(i%2) + 3*(i%3) + 19;

  for(int i=0;i<17;i++)c[i] = -1;

  time = 0;
  bool ex = false;
  while(1){
    if( !(time%5) )q.push(time/5);
    int tmp = -1;
    for(int i=0;i<17;i++){
      if(c[i]>=0 && c[i]!=tmp){
	t[c[i]]--;
	tmp = c[i];
      }
      if(!t[c[i]])c[i] = -1;
    }
    while(q.size()){
      int n,i;
      if(q.front()%5 == 1)n = 5;
      else n = 2;
      for(i=0;i+n<=17;i++){
	bool f = true;
	for(int j=i;j<i+n;j++){
	  if(c[j]>=0)f = false;
	}
	if(f){
	  if(q.front() == 99)ex = true;
	  for(int j=i;j<i+n;j++)c[j] = q.front();
	  ans[q.front()] = time - q.front()*5;
	  q.pop();
	  break;
	}
      }
      if(ex)break;
      if(i+n==18)break;
    }
    if(ex)break;
    time++;
  }

  int num;
  while(cin >> num)cout << ans[num] << endl;
}