Check this code plz

import java.util.;
public class Main {
public static void main(String args[]) {
Scanner in=new Scanner(System.in);
int N=in.nextInt();
int a[]=new int[N];
int b[]=new int[N];
for(int i=0;i<N;i++)
{
a[i]=in.nextInt();
b[i]=in.nextInt();
}
int gap1,gap2;
int min1 = a[0];
int max1 = a[0];
for (int i = 0; i < N; i++)
{
if (a[i] > max1)
max1 = a[i];
if (a[i] < min1)
min1 = a[i];
}
gap1=Math.abs(min1 - max1);
min1 = b[0];
max1 = b[0];
for (int i = 0; i < N; i++)
{
if (b[i] > max1)
max1 = b[i];
if (b[i] < min1)
min1 = b[i];
}
gap2=Math.abs(min1 - max1);
//System.out.println(gap1+" "+gap2);
long area=(gap1-2)
(gap2-2);
System.out.print(area);

}

}

hey @Rajput.apry
your logic is wrong
try for this input :
3
6 8
3 8
11 2
correct output 20
This is a pretty simple problem. All we need to do is just store all the X and Y coordinates and then sort them. Then we will calculate maximum ΔX and ΔY where ΔX = (Xi -Xi-1) & ΔY = (Yi -Yi-1). Then the area will be (ΔY-1)*(ΔX-1)