import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class Main {
    // ?¨???¢??°?????§???
    static final int MAX_NUMBER_OF_VISITOR = 100;

    // ??§?????°
    static final int NUMBER_OF_SEAT = 17;

    // ??°???????????°??\??????
    static final int INTERVAL = 5;

    // ??????????????????
    static int[] waitingTime = new int[MAX_NUMBER_OF_VISITOR];

    // ???????????§????????¶???
    static int[] shopSeatTimer = new int[NUMBER_OF_SEAT];

    public static void main(String[] args) {

	// ?¨??????\???
	Scanner sc = new Scanner(System.in);

	List<Integer> orders = new ArrayList<>();

	while (sc.hasNextLine()) {
	    String nextLine = sc.nextLine();
	    if ("".equals(nextLine)) {
		break;
	    }
	    orders.add(Integer.parseInt(nextLine));
	}

	// ??\???????????????????????§????????????
	int maxOrder = returnMax(orders);

	// ????????????????????????
	Arrays.fill(waitingTime, -1);

	// ?????\?????¬????????§?????????
	executeSimulation(maxOrder);

	// ??????????????°?????????????????????????????????
	for (Integer order : orders) {
	    System.out.println(waitingTime[order]);
	}

	sc.close();

    }

    private static void executeSimulation(int maxOrder) {
	// ????????????
	List<Integer> waintinGroup = new ArrayList<>();

	// ???????????§???????????????(?????????-1??¨??????)
	Arrays.fill(shopSeatTimer, -1);

	// ????????????????????????????§?

	for (int now = 0;; now++) {

	    // ?£?????????????????????????????????????????????????????£????????????????-1
	    for (int i = 0; i < NUMBER_OF_SEAT; i++) {

		// ????????????????????????????????????????????????
		if (shopSeatTimer[i] != -1) {
		    shopSeatTimer[i]--;
		    // ???????????????0???????????????
		    if (shopSeatTimer[i] == 0) {
			shopSeatTimer[i] = -1;
		    }
		}

	    }

	    // ??°??????????????°????????????????????¶
	    if (now % INTERVAL == 0) {
		waintinGroup.add(now / INTERVAL);
	    }

	    // ????????????????????§???
	    while (true) {
		if (waintinGroup.isEmpty()) {
		    break;
		}

		int group = waintinGroup.get(0);
		int openSeatHead = canISitDown(group);

		// ???????????????????????°
		if (openSeatHead != -1) {
		    // ????????????????????????????´?
		    waitingTime[group] = now - group * INTERVAL;

		    // /**
		    // * ???????????°
		    // */
		    // System.out.println("??°??????????????????" + group);
		    // System.out.println("????????????" + waitingTime[group]);
		    // System.out.println(openSeatHead);
		    // for (int i = 0; i < NUMBER_OF_SEAT; i++) {
		    // System.out.print(shopSeatTimer[i] + ",");
		    // }
		    // System.out.println();
		    // /*
		    // *
		    // */

		    // ?£?????????????????´?
		    for (int i = 0; i < howManymembers(group); i++) {
			shopSeatTimer[openSeatHead + i] = howLongToEat(group);
		    }
		    // ??????????????????
		    waintinGroup.remove(0);

		    // ?±??????????????????§??????????????°?????????????????????????????????
		    if (group == maxOrder) {
			return;
		    }

		} else {
		    break;
		}

	    }

	}

    }

    // ????????????????????§????????????
    private static int returnMax(List<Integer> orders) {
	int maxOrder = 0;
	for (Integer order : orders) {
	    maxOrder = Math.max(order, maxOrder);
	}
	return maxOrder;

    }

    // ??§?????????????????????
    private static int canISitDown(int group) {
	int count = 0;
	for (int i = 0; i < NUMBER_OF_SEAT - howManymembers(group) + 1; i++) {
	    for (int j = 0; j < howManymembers(group); j++) {
		if (shopSeatTimer[i + j] == -1) {
		    count++;
		} else {
		    count = 0;
		    break;
		}

		if (count == howManymembers(group)) {
		    return i;
		}
	    }
	}
	return -1;
    }

    // ????????°?????????????????????
    private static int howManymembers(int group) {
	return group % 5 == 1 ? 5 : 2;
    }

    // ?£???????????????????
    private static int howLongToEat(int group) {
	return 17 * (group % 2) + 3 * (group % 3) + 19;
    }
}

Measured memory_bytes: 26044