Help me in solving ZCO13001 problem

My issue

(Partially correct)

My code

#include <iostream>
using namespace std;
int absolute(int n){
    if(n>=0)
    return n;
    else
    return -n;
}


int main() {
	int N;
	cin >> N;
	long teams[N];
	int price=0;
	for(int i=0;i<N;i++){
	    cin >> teams[i];
	}
	int lim=(N * (N-1))/2;
	for(int i=0;i<N;i++){
	    for(int j=i+1;j<N;j++){
	        price+=absolute(teams[j]-teams[i]);
	    }
	}
	cout << price;
	return 0;
}

Problem Link: CodeChef: Practical coding for everyone