• + 0 comments

    public static int solve(List V) { int n=V.size(),c=0; int x = 2*n/2*(n-n/2)*100000; Collections.sort(V);

    for(int i=0;i<n-1;i++)
    {
        if(V.get(i+1)-V.get(i) == 1)
        {
            c++;
            i++;
        }
    }
    if(V.get(n-1) - V.get(0) == 1)
        c++;
    x+=c;
    return x*2; 
    

    }

    }