Language: Java


		ai[n-1] = arr[n-2];
		
		for(int i=1;i<n-1;i++){
			if(arr[i-1]<=arr[i])
				ai[i]=arr[i-1];
			else ai[i]=arr[i];
		}
		long total=0;
		for(int i=0;i<n;i++)
			total+=ai[i];
		
		System.out.println(total);
		
		out.close();
	}
	
	
	
	
	
	//static HashMap<Integer,Integer> visited = new HashMap<>();
		
	
	/*public static int compute(int root, int n, int m, Tree[] edge, int values[]){
			
			LinkedList<Integer> ll = 	new LinkedList<>();
			ll.add(root);
				
			while(ll.size()>0){
				int val = ll.removeFirst();
				visited.put(val,0);
				ArrayList<Integer> al = edge[val].al;
				int length = al.size();
				for(int i=0;i<length;i++){
					ll.addLast(al.get(i));
					int hold = edge[val].weight+values[root];
					values[al.get(i)] = Math.min(hold,values[al.get(i)]);
				}
			}
			return values[n];
			
	}*/
	
	
	public static class Tree{
		int weight;
		int destination;
	}
	
	
	
	public static int partition(int [] arr, int s, int e){
		
		int index=s;
		int pivot = arr[e];
		for(int i=s;i<=e-1;i++){
			if(arr[i]<=pivot){
				arr = swap(arr, index, i);
				index++;
			}
		}
		swap(arr,index,e);
		print(arr);
		return index;
	}
	
	public static int[] swap(int[] arr, int low, int high){
		int temp = arr[low];
		arr[low]=arr[high];
		arr[high]=temp;
		return arr;
	}
	
	
	public static long gcd(long a, long b){
		if(a==0)
			return b;
		
		return gcd(b%a,a);
	}
	
	public static void print(int[] arr){
		for(int i=0;i<arr.length;i++)
			System.out.print(arr[i]+" ");
		System.out.println();
	}
	
	public static class pair{
		int ai;
		int bi;
	}
	
	public static class comp implements Comparator<pair>{
		public int compare(pair o1, pair o2){
			return o1.bi-o2.bi;
		}
	}
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
}

Compiler output:
Main.java:2: error: class, interface, enum, or record expected
		ai[n-1] = arr[n-2];
		^
Main.java:4: error: class, interface, enum, or record expected
		for(int i=1;i<n-1;i++){
		^
Main.java:4: error: class, interface, enum, or record expected
		for(int i=1;i<n-1;i++){
		            ^
Main.java:4: error: class, interface, enum, or record expected
		for(int i=1;i<n-1;i++){
		                  ^
Main.java:7: error: class, interface, enum, or record expected
			else ai[i]=arr[i];
			^
Main.java:8: error: class, interface, enum, or record expected
		}
		^
Main.java:10: error: class, interface, enum, or record expected
		for(int i=0;i<n;i++)
		^
Main.java:10: error: class, interface, enum, or record expected
		for(int i=0;i<n;i++)
		            ^
Main.java:10: error: class, interface, enum, or record expected
		for(int i=0;i<n;i++)
		                ^
Main.java:13: error: class, interface, enum, or record expected
		System.out.println(total);
		^
Main.java:15: error: class, interface, enum, or record expected
		out.close();
		^
Main.java:16: error: class, interface, enum, or record expected
	}
	^
Main.java:53: error: unnamed classes are a preview feature and are disabled by default.
	public static int partition(int [] arr, int s, int e){
	              ^
  (use --enable-preview to enable unnamed classes)
Main.java:142: error: class, interface, enum, or record expected
}
^
14 errors