/*
Online Java - IDE, Code Editor, Compiler

Online Java is a quick and easy tool that helps you to build, compile, test your programs online.
*/

public class Main
{
    public static void main(String[] args) {
        System.out.println("Welcome to Online IDE!! Happy Coding :)");
        int [] num = new int[]{2,6,4,12,5};
        int [][] sum = new int[num.length][num.length];
        int temp=0;
        int [] runningTotal = new int [num.length];
        int [] Total = new int [num.length];
        int [] fullRunningTotal = new int[num.length];
        //int highestArray=k;
       
        for (int i=0;i<num.length;i++)
        {
            sum[i][0]=num[i];  // this stores the present number
            System.out.println("Number being observed: " + num[i]);
            
            for (int j=0; j<num.length; j=j+2)
            {
                if (j==i  && j!=num.length-1)   // this ensures that only adjacent numbers are summed up
                {
                    j=j+2;
                }
               
                if (j!=num.length)
                {
                    System.out.println("This is: " + i + " execution");
                    sum[i][j]=num[j];  // this stores the adjacent numbers that are being examined
                    System.out.println(num[j]);
                    
                    runningTotal[i] = runningTotal[i] + num[j]; // this keeps total of all adjacent numbers except original
                   
                }
                
                fullRunningTotal[i] = runningTotal[i]+num[i]; //this keeps total including original
               
            }
        }
       
        for (int k=0; k<num.length; k++)
        {
            System.out.println("Running totals are:" + fullRunningTotal[k]);
           
            if (fullRunningTotal[k]>temp)
            {
                temp=fullRunningTotal[k];
                
            }
           
        }
        System.out.println("Highest sum is:" + temp);
       
    }
}