Banks have been introducing various innovative deposit heroes to expand their services to Customers. One of the schemes is known as the Rainy Day Fund, where a person should invest a certain amount every year. The investment can be done only under the following conditions:

The amount invested in the year y1 in the first cycle should be equal to Rs 1.

The amount invested every year should be exactly Rs 1 more than that in the previous year. Once the period of 7 years is over, the investment cycle will start from y1 again, which means y1, y2,y3, y4, y5,y6, y7,y1, y2, y3, y4, y5, y6. and so on,

In this case, the amount invested in any year this cycle will be Rs 1 more than the investment In corresponding year in the previous cycle.

Suppose in the first cycle of 7 years, the investment is y1 = 1, y2 = 2 y3 = 3 .. y7 = 7. In the second cycle, it should y1=2 ,y2=3,y3 = 4. y7=Rs 8

The task here is to help the investor to  calculate the total amount of money he/she has invested in the ‘N’ years, where 'N’ denotes the number of years.

Example 1:

5

Output

30

 

Code:

import java.util.Scanner;

 

public class TCS {

 

     public static void main(String[] args) {

         // TODO Auto-generated method stub

         Scanner sc = new Scanner(System.in);

        

         int n =sc.nextInt();

         int sum=0,c=1;

        

         if(n>=8)

         {

              c++;

              for(int i=0;i<=7;i++)

              {   

                  sum+=i;

                 

              }

              for(int j=0;j<=(n-8);j++)

              {

                  sum=sum+(c+j);

              }

         }

         else

         {

              for(int i=0;i<=n;i++)

              {   

                  sum+=i;

                 

              }

         }

         System.out.println(sum);

        

     }

    

 

}

 

 

Output: