What is wrong with my code ?

I am having trouble with ZCO14003 (Zonal Computing Olympiad 2014, 30 Nov 2013)
I am getting a wrong answer on task 3 and onward, except for task 6.
here is my code in C:

#include <stdio.h>

int main() {
int j, p = 0,i,k,l;
int rmax[100000];
long long b[100000], m,n,RMAX;
scanf("%lld", &n);
for (i = 0; i < n; i++) {
scanf("%lld", &b[i]);
}
for (j = 0; j < n; j++) {
m = b[j];
p = 0;
for (k = 0; k < n; k++) {
if (b[j] <= b[k]) {
p++;
}
rmax[j] = m*p;
}
}
RMAX = rmax[0];
for (l = 0; l < n; l++) {
if (rmax[l] > RMAX) {
RMAX = rmax[l];
}
}
printf("%lld", RMAX);
return 0;
}

Thanks !

//