public static void main ( String [] args ) {
	
	boolean flag = true;
	int i = 1, p1=0, p2=0;

	while ( flag ) {
	    p1 = i*(3*i-1)/2;
	    for ( int j=i-1; j>0; j-- ) {
		p2 = j*(3*j-1)/2;

		if ( isPan(Math.abs(p1-p2)) && isPan(Math.abs(p1+p2)) ) {
		    System.out.print("D = ");
		    System.out.println(p1-p2);
		    flag = false;
		}
	    }
	    i++;
	}

    }