#include<vector>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int seat[17];
vector<int> rm[5000];
queue<int> q;
int result[100];

int ck(int c){
	c=c%5==1?5:2;
	int suc=0;
	rep(i,17){
		if(seat[i]==-1){
			suc++;
			if(suc==c)return i-suc+1;
		}
		else suc=0;
	}
	return -1;
}
void in(int c,int p,int t){
	int n=c%5==1?5:2;
	rep(i,n)seat[i+p]=c;
	rm[5*c+17*(c%2)+3*(c%3)+19].push_back(c);
	result[c]=t-5*c;
	q.pop();
}
void remove(int c){
	rep(i,17)if(seat[i]==c)seat[i]=-1;
}
int main(){
	rep(i,17)seat[i]=-1;
	
	for(int t=0;t<=500||!q.empty();t++){
		if(t%5==0)q.push(t/5);
		rep(i,rm[t].size())remove(rm[t][i]);
		if(q.empty())continue;
		for(int p=ck(q.front());p>=0&&!q.empty();p=ck(q.front()))in(q.front(),p,t);
	}
	
	int n;
	while(cin>>n)cout<<result[n]<<endl;
	return 0;
}