#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int blank(const vi& table,int num)
{
	rep(i,table.size()-num+1){
		bool flg=true;
		rep(j,num)
			if(table[i+j])
				flg=false;
		if(flg)
			return i;
	}
	return -1;
}

int main()
{
	vi table(17);
	deque<int> customers;
	vi res(100);
	rep(t,1000){
		rep(i,table.size())
			table[i]=max(table[i]-1,0);
		if(t<=500 && t%5==0)
			customers.push_back(t/5);
		while(customers.size()){
			int customer=customers[0];
			int num=customer%5==1?5:2;
			int index=blank(table,num);
			if(index==-1)
				break;;
			res[customer]=t-customer*5;
			rep(i,num)
				table[index+i]=17*(customer%2)+3*(customer%3)+19;
			customers.pop_front();
		}
	}
	
	for(int n;cin>>n;)
		cout<<res[n]<<endl;
	
	return 0;
}