#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int seat[17];
int res[200];

int main() {
	int i;
	int j;
	int k=-1;
	for(i=0;i<600;i++){
//cout<<i<<endl;
		for(j=0;j<17;j++){
			if(seat[j])seat[j]--;
//cout<<" "<<j<<" "<<seat[j]<<endl;
		}
		if(k==-1){
			if(i%5==0){
				k=i/5;
			}
		}
		while(1){
			int l;
			if(k==-1)break;
			if(k%5==1){
				for(l=0;l<=17-5;l++){
					if(seat[l]+seat[l+1]+seat[l+2]+seat[l+3]+seat[l+4]==0){
						seat[l]=seat[l+1]=seat[l+2]=seat[l+3]=seat[l+4]=17*(k%2)+3*(k%3)+19;
						res[k]=i-k*5;
						k++;
						if(k>i/5)k=-1;
						goto a;
					}
				}
			}else{
				for(l=0;l<=17-2;l++){
					if(seat[l]+seat[l+1]==0){
						seat[l]=seat[l+1]=17*(k%2)+3*(k%3)+19;
						res[k]=i-k*5;
						k++;
						if(k>i/5)k=-1;
						goto a;
					}
				}
			}
			break;
			a:;
		}
//cout<<i<<endl;
//for(j=0;j<17;j++){
//	cout<<" "<<j<<" "<<seat[j]<<endl;
//}
//cout<<"  "<<k<<endl;
	}
	int n;
//for(n=0;n<200;n++){
//	cout<<n<<" "<<res[n]<<endl;
//}
	while(cin>>n){
		cout<<res[n]<<endl;
	}
	return 0;
}

//WA