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

int search_sequence(vector<int> &a,int n){
	int cnt=0;
	for(int i=0;i<a.size();++i){
		if(a[i]==-1)++cnt;
		else cnt=0;
		if(cnt>=n)return i-cnt+1;
	}
	return -1;
}

int main(void){
    vector<int> seat(17,-1);
    int time[100],finish[100];
    queue<pair<int,int> > q;
    int x=0,y=0;
    for(int t=0;y<100;++t){
      if(t%5==0) q.push(make_pair(x++,(x%5==1)?5:2));
      for(int i=0;i<17;++i){
        if(seat[i]!=-1&&finish[seat[i]]==t){
        	fill(&seat[i],&seat[i+((seat[i]%5==1)?5:2)],-1);
        	//cerr<<t<<":";for(int i=0;i<17;++i)cerr<<seat[i]<<((i!=16)?" ":"\n");
      	}
      }
      while(search_sequence(seat,q.front().second)!=-1){
        fill(&seat[search_sequence(seat,q.front().second)],&seat[search_sequence(seat,q.front().second)+q.front().second],q.front().first);
        //cerr<<t<<":";for(int i=0;i<17;++i)cerr<<seat[i]<<((i!=16)?" ":"\n");
        finish[q.front().first]=t+17*(q.front(
        ).first%2)+3*(q.front().first%3)+19;
        time[q.front().first]=t-5*q.front().first;
        q.pop();++y;
      }
    }
  int n;
  while(cin>>n){
  	cout<<time[n]<<endl;
  }
  return 0;
}