#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

int dp[20],in[20],ans[111],t,id;
queue<int>q;

void dele(){
  r(i,17)if(dp[i]!=-1){
    int x=17*(dp[i]%2)+3*(dp[i]%3)+19;
    if(in[i]+x<=t)dp[i]=-1;
  }
}

void inse(){
  while(!q.empty()){
    int x=q.front();
    int n,flag=0;;
    if(x%5==1)n=5;
    else n=2;
    r(i,17)if(dp[i]==-1){
      if(i+n>17)continue;
      int f=0;
      r(j,n)if(dp[i+j]!=-1)f=1;
      if(f)continue;
      r(j,n){
        in[i+j]=t;
        dp[i+j]=x;
        flag++;
      }
      ans[x]=t-5*x;
      break;
    }
    if(flag)q.pop();
    else break;
  }
}

int main(){
  memset(dp,-1,sizeof(dp));
  for(t=0;t<1000000;t++){
    if(t%5==0&&id<=100)q.push(id++);
    dele();
    inse();
  }
  int n;
  while(cin>>n)cout<<ans[n]<<endl;
}
