ZCO smart phone

Hey! My code on java does not work. It gives an answer for all but it gives one of them wrong. Pls help. Thanks in advance
import java.util.*;

class PP1 {

public static long rev(long b[], long x) {
	long t = Search(b, x);
	long reve = (t + 1);
	reve *= x;
	return reve;

}

public static long Search(long a[], long x) {
	for (int i = 0; i < a.length; i++) {
		if (x == a[i]) {
			return i;
		}
	}
	return x;
}

public static long[] Sort(long array[]) {//Decreasing order
	long n = array.length;
	long temp;
	int k;
	for (long m = n; m >= 0; m--) {
		for (int i = 0; i < n - 1; i++) {
			k = i + 1;
			if (array[i] < array[k]) {

				temp = array[i];
				array[i] = array[k];
				array[k] = temp;
			}
		}
	}
	return array;
}

public static void main(String args[]) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	long a[] = new long[n];
	for (int i = 0; i < n; i++) {
		a[i] = sc.nextLong();
	}
	long max = 0;
	a = Sort(a);
	for (int x = 0; x < n; x++) {
		long check = rev(a, a[x]);
		if (check > max) {
			max = check;
		}
	}
	System.out.println(max);
}

}