this is the code
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[] arr=new int[n];
for(int i=0;i<n;i++)
{
arr[i]=sc.nextInt();
}
boolean flag=true;
int d=0;
for(int i=1;i<n;i++)
{
d=arr[i]-arr[i-1];
if((arr[i-1]+d)!=arr[i])
{
flag=false;
break;
}
}
System.out.println(flag);
}
}