Preview:
import java.util.Scanner;
public class sum {
    
  public static int arraysum(int
[][]arr,int n)  
    {
        
        
  int left =0;
  int right =0;
  int abs=0;
for(int I=0;I<arr.length;I++) 
    {
        
for(int J=0;J<arr.length;J++)   
 {
    
  if (I==J)
left+=arr[I][J];
if (I+J==n-1) 
right+=arr[I][J];
}
}

abs=left-right;



      return  abs;
    }
       
    
 public static void main(String 
[]args)
 
    {
 Scanner input =new Scanner
(System.in);
        int n;
        n=input.nextInt();
        int[][]ARR=new int[n][n]
;
        for (int i=0;i<n;i++) 
        {
           for (int j=0;j<n;j++)
           {
  ARR[i][j]=input.nextInt();
               
           }
                     }   System.out.print(Math.abs(arraysum(ARR,n)));         }      
        
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter