For this Question: There is a row of N shops. Each shop sells A[i] candies. Your friend made an array B of (N-1) integers where B[i] = max(A[i], A[i+1]) for i from 1 to (N-1). You are given array B. You want to generate the array A such that the sum of values of the candies in A is maximum. Find the maximum possible sum of candies of array A.The first line of input contains a single integer N. 
The second line of input contains (N-1) integers denoting array B.

<b>Constraints:</b>
2 &le; N &le; 10<sup>5</sup>
1 &le; B[i] &le; 10<sup>9</sup>Print the maximum possible sum of the candies in array A.Sample Input
4
1 3 4

Sample Output
9

<b>Explanation:</b> 
Optimal Array A will be [1, 1, 3, 4], I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long b[] =  new long[n-1];
	   long sum=0;
	   for(int i=0;i<n-1;i++)
	   {
			b[i] = sc.nextLong();
	   }

		for(int i=0;i<n-2;i++)
	   {
		   if(b[i]>b[i+1])
		   {
		   		sum += b[i+1];
		   }
		   else
		   {
		   		sum += b[i];
		   }
	   }
	   	sum += b[n-2];
		System.out.println(sum+b[0]);
	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?