Question

# Share code with your friends

Code

```				```
import java.util.Scanner;

public class Pseudoarithmetic
{
int n,sum,r;
boolean  ans,flag;
int a[];
public Pseudoarithmetic()
{
ans=true;
flag=true;
}
public void accept(int nn)
{
int i=0;
Scanner sc=new Scanner(System.in);
n=nn;
a=new int[n];
System.out.println("Enter" +n + "elements");
for(i=0;i< n;i++)
{
a[i]=sc.nextInt();
}
}
public boolean check()
{
int i=0,j=0;
r=a[0]+a[n-1];
if(n%2==0)
{
for(i=0;i< n/2;i++)
{
if((a[i]+a[n-1-i])!=r)
{
flag=false;
}
}
}
else
{
for(j=0;j<= n/2;j++)
{
if((a[j]+  a[n-1-j])!=r)
{
ans=false;
}
}
}
if(flag==true)
{
sum=n/2*r;
}
if(ans=true)
{
sum=(n/2+1)*r;
}
if(ans==false || flag==false)
{
return false;
}
else
{
return true;
}
}
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("enter size of sequence");
int nn=sc.nextInt();
Pseudoarithmetic ob1=new Pseudoarithmetic();
ob1.accept(nn);
System.out.println(ob1.check());
}
}

```
```

Sale

50
Sale

150
Sale

200
Sale

50
Sale

50
Sale

50
Sale

50
Sale

50
Sale

50