Find the sum(PAIRSUM2)

I am getting run time error in this code. This was the problem of September lunchtime. Sub task 1 is submitted successfully but in sub task it’s giving RE.
Please some one help me to identify the error
`import java.util.Scanner;

class FindTheSum {
long a[];
long dp[][];
public static void main(String args[]){
Scanner sc = new Scanner(;
int t = sc.nextInt();

        FindTheSum o = new FindTheSum();
        int N = sc.nextInt();
        int Q = sc.nextInt();
       o.a = new long[N];
     o.dp= new long [N+1][N+1];
       for(int i=1;i<=N-1;i++){
           o.a[i] = sc.nextLong();
       int x,y;
       for(int i=1;i<=Q;i++){
           x = sc.nextInt();
           y = sc.nextInt();
           int max = Math.max(x, y);
           int min = Math.min(x,y);
           x = min; y = max;
           long ans = o.getValue(x, y);
           o.dp[x][y] = ans;


private long getValue(int x, int y) {
           return a[y-1];
        else if((x%2==0&&y%2==0)||(x%2!=0&&y%2!=0)){
            return -1;
        else if(x%2==0||x%2!=0){
                return dp[x][y-2]+a[y-1]-a[y-2];
            return getValue(x,y-2)+a[y-1]-a[y-2];
        return 0;



In java array should be declared as an object
Direct declaration of arrays is not allowed

array is declared properly, no compilation error