#include<bits/stdc++.h>
using namespace std;

struct G{
  int group, people, now, time;
};

int main(){
  int minutes[100];
  int chair[17]; //あーじゅうななせきあった！！
  fill_n( chair, 17, 0);

  queue< G > mati;

  for(int i = 0; i < 10000; i++){
   if(i % 5 == 0 && i / 5 < 100){ //group leave
      int group = i / 5;
      mati.push((G){ group, group % 5 == 1 ? 5 : 2, i, 17 * (group % 2) + 3 * (group % 3) + 19});
    }


    while(!mati.empty()){
      G& g = mati.front();
      int count = 0, pos = -1;
      for(int j = 0; j < 17; j++){
        if(!chair[j]){
          count++;
          if(count == g.people){
            pos = j - g.people + 1;
            break;
          }
        }else{
          count = 0;
        }
      }
      if(pos != -1){
        minutes[g.group] = i - g.now;
        for(int j = pos; j < pos + g.people; j++){
          chair[j] = g.time;
        }
        mati.pop();
      } else {
        break;
      }
    }

    for(int j = 0; j < 17; j++){
      if(chair[j] > 0) chair[j]--;
    }

  }
  int n;
  while(cin >> n){
    cout << minutes[n] << endl;
  }
}