A logic error in my program

Code:

`/*To find out the value in the array that the sum of all elements of the same number is the largest*/`

/* Can anyone tell me what the logic error is? Thanks. */

int findMaxValue(int arr[], int n){ //n = number of elements in array

int ans=0;

int maxValue = 0;

int temp[80]; //maximum of array lenth is 80

int i,j;

for(i=0; i<n; i++){

for(j=1; j<100; j++){ //the value in array is from 0 to 100

if(arr[i] == j)

temp[j] += j;

}

}

for (j=1; j<100; j++){

if(temp[j] > maxValue){

maxValue = temp[j];

ans = j;

}

}

return ans;

}

//Thank you.