"Fukusekiken" is a popular ramen shop where you can line up. But recently, I've heard some customers say, "I can't afford to have vacant seats when I enter the store, even though I have a long waiting time." I'd like to find out why such dissatisfaction occurs, but I'm too busy to check the actual procession while the shop is open. However, since I know the interval and number of customers coming from many years of experience, I decided to analyze the waiting time based on that.

There are 17 seats in the store facing the counter. The store opens at noon, and customers come as follows.

* 100 groups from 0 to 99 will come.
* The i-th group will arrive at the store 5i minutes after noon.
* The number of people in the i-th group is 5 when i% 5 is 1, and 2 otherwise.
(x% y represents the remainder when x is divided by y.)
* The i-th group finishes the meal in 17 (i% 2) + 3 (i% 3) + 19 minutes when seated.



The arrival times, number of people, and meal times for the first 10 groups are as follows:

Group number | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
Arrival time (minutes later) | 0 | 5 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45
Number of people (people) | 2 | 5 | 2 | 2 | 2 | 2 | 5 | 2 | 2 | 2
Meal time (minutes) | 19 | 39 | 25 | 36 | 22 | 42 | 19 | 39 | 25 | 36



In addition, when guiding customers to their seats, we do the following.

* Seats are numbered from 0 to 16.
* A group of x people can only be seated when there are x open seats in a row.



Also, if there are multiple places to sit, sit in the place with the lowest seat number. For example, if only seats 0, 1, 2, 4, and 5 are available, a group of 5 people cannot be seated. If you are in a group of two, you will be seated at number 0 and 1.

* Once you are seated, you will not be asked to move your seat.
* Customers come and go in 1 minute increments. At each time, we will guide customers in the following order.
1. The next group can be seated at the same time as the previous group leaves.
2. When seating customers, seat as many groups as possible at the same time, starting with the group at the top of the line. It does not overtake the order of the matrix. In other words, if the first group cannot be seated, even if other groups in the procession can be seated, they will not be seated.
3. Groups arriving at that time will line up at the end of the procession, if any. If there is no line and you can sit down, you will be seated, and if you cannot, you will wait in line. As an example, the following shows how the first 10 groups arrive. From left to right, the three columns in each row show the time, seating, and queue. For seats, the "_" is vacant and the number indicates that the group with that number is sitting in that seat.




Time: Seat procession
0: 00 _______________:
5: 0011111 ___________:
10: 001111122 ________:
15: 00111112233______:
18: 00111112233______:
19: __111112233______:
20: 44111112233 ______:
25: 4411111223355____:
30: 4411111223355____: 66666 Group 6 arrives
34: 4411111223355____: 66666
35: 4411111__3355____: 6666677 Group 7 arrives
40: 4411111__3355____: 666667788 Group 8 arrives
41: 4411111__3355____: 666667788
42: __11111__3355____: 666667788
43: __11111__3355____: 666667788
44: 6666677883355____: Groups 6, 7 and 8 are seated
45: 666667788335599__: Group 9 arrives and sits down


For example, at time 40, the eighth group arrives, but cannot be seated and joins the procession. The fourth group eats until time 41. At time 42, seats in the 4th group are available, but the 6th group is not yet seated due to the lack of consecutive seats. The first group eats until time 43. At time 44, the first group will be vacant, so the sixth group will be seated, and at the same time the seventh and eighth groups will be seated. The ninth group arrives at time 45 and will be seated as they are available.

Based on this information, create a program that outputs the time (in minutes) that the nth group of customers waits by inputting an integer n that is 0 or more and 99 or less.



Input

Given multiple datasets. Each dataset consists of one integer n.

The number of datasets does not exceed 20.

Output

For each dataset, print the minute wait time (integer greater than or equal to 0) for the nth customer on a single line.

Example

Input

5
6
7
8


Output

0
14
9
4
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    /** 座席数 */
    private final static int SEATS = 17;

    /** 客グループ数 */
    private final static int GROUP = 100;

    /** 客グループの到着する間隔（分） */
    private final static int INTERVAL = 5;

    /** 客グループの待ち時間を格納する配列 */
    private static int[] watingTimes = new int[GROUP];

    /** 客グループの到着時刻、人数、食事時間を格納する二次元配列 */
    private static int[][] groupInfo = new int[GROUP][3];

    /** 客グループの到着時刻を表す添え字 */
    private final static int GROUP_INFO_ARRIVAL = 0;

    /** 客グループの人数を表す添え字 */
    private final static int GROUP_INFO_PERSONS = 1;

    /** 客グループの食事時間を表す添え字 */
    private final static int GROUP_INFO_EATING_MINUTES = 2;

    /** 座席の着席状況を格納する配列 */
    private static int[] seatsCondition = new int[SEATS];

    /** お店が開いているかどうか */
    private static boolean openFlag = true;

    /** 最後に到着したグループ */
    private static int lastArrivalGroup = -1;

    /** 待ちグループ数 */
    private static int watingGroups = 0;

    /** 正午からの経過時間（分） */
    private static int passedMinutes = 0;

    /**
     * <p>
     * 「福縞軒」に訪れる客グループの待ち時間を算出する。
     * </p>
     *
     * @param args
     *            利用しない。
     * @throws IOException
     * @throws NumberFormatException
     */
    public static void main(String[] args) throws NumberFormatException,
            IOException {

        // 入力値の読み込み
        List<Integer> inputList = getInput();

        // 全客グループの到着時間と人数と食事時間を求める
        setGroupInfo();

        while (openFlag) {

            // 等間隔で次のグループが到着する
            if (passedMinutes % INTERVAL == 0) {
                lastArrivalGroup++;
                watingGroups++;
            }

            // 待ちグループがいなければ何もせずに時刻を進める
            if (watingGroups == 0) {
                passedMinutes++;
                continue;
            }

            // 待ちグループが存在した場合
            // 待ちの先頭グループ番号を求める
            int nextGroup = lastArrivalGroup - watingGroups + 1;

            // 待ちグループがいて、空席が存在する場合　※最初の１回は必ず空席チェックする
            boolean vacancyFlag = true; // 空席が存在するかのフラグ
            while (watingGroups != 0 && vacancyFlag) {

                // 待ちの先頭グループの人数を求める
                int numberOfPersons = groupInfo[nextGroup][GROUP_INFO_PERSONS];

                // 退席時刻となった席を空席にし、先頭のグループが着席できる座席の番号を求める
                int seatNumber = getSeatNumber(numberOfPersons);

                if (seatNumber != -1) {

                    // 着席できる座席があった場合、座席にグループの退席時刻を設定する
                    for (int i = 0; i < numberOfPersons; i++) {
                        seatsCondition[seatNumber] = passedMinutes
                                + groupInfo[nextGroup][GROUP_INFO_EATING_MINUTES];
                        seatNumber++;
                    }

                    // グループの待ち時間を設定する
                    watingTimes[nextGroup] = passedMinutes
                            - groupInfo[nextGroup][GROUP_INFO_ARRIVAL];

                    // 待ちグループ数を減らす
                    watingGroups--;
                    nextGroup = lastArrivalGroup - watingGroups + 1;

                    // 最後のグループが座ったら、お店を閉店する
                    if (nextGroup == GROUP) {
                        openFlag = false;
                        vacancyFlag = false;
                    }
                } else {
                    vacancyFlag = false;
                }
            }

            passedMinutes++;
        }

        // 結果を出力する
        for (int i : inputList) {
            System.out.println(watingTimes[i]);
        }
    }

    /**
     * <p>
     * 入力値（n番目のグループ）を取得する
     * </p>
     *
     * @return 入力値のリスト
     * @throws NumberFormatException
     * @throws IOException
     */
    private static List<Integer> getInput() throws NumberFormatException,
            IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        List<Integer> inputList = new ArrayList<Integer>();

        String line = null;
        while ((line = br.readLine()) != null) {
            inputList.add(Integer.parseInt(line));
        }

        return inputList;
    }

    /**
     * <p>
     * 客グループの到着時刻、人数、食事時間を計算し、配列にセットする
     * </p>
     */
    private static void setGroupInfo() {

        for (int i = 0; i < GROUP; i++) {
            groupInfo[i][GROUP_INFO_ARRIVAL] = i * INTERVAL;
            groupInfo[i][GROUP_INFO_PERSONS] = (i % 5 == 1 ? 5 : 2);
            groupInfo[i][GROUP_INFO_EATING_MINUTES] = 17 * (i % 2) + 3
                    * (i % 3) + 19;
        }

    }

    /**
     * <p>
     * 退席時刻となった席を空席にする。<br/>
     * 引数で受け取った人数が座れる席を探し、座席番号を返す。<br/>
     * 座席がない場合は-1を返す。
     * </p>
     *
     * @param numberOfPersons
     *            人数
     * @return 座席番号
     */
    private static int getSeatNumber(int numberOfPersons) {

        int seatNumber = 0; // 先頭の座席番号
        int vacancySeats = 0; // 空席数

        for (int i = 0; i < SEATS; i++) {

            // 退席時刻となった座席を空席に戻す
            if (seatsCondition[i] <= passedMinutes) {
                seatsCondition[i] = 0;
            }

            if (seatsCondition[i] == 0) {

                // 席が空席であれば、空席数を増やす
                vacancySeats++;

                // 空席数が待ち人数と等しければ、先頭の座席番号を返す
                if (vacancySeats == numberOfPersons) {
                    return seatNumber;
                }
            } else {

                // 席が空席でなければ、座席番号を次に移し、空席数を0に戻す
                seatNumber = i + 1;
                vacancySeats = 0;
            }
        }

        // 空席がなければ-1を返す
        return -1;
    }
}