import java.util.Scanner;

public class Main {
  public static void main(String ...args) {
    final Scanner scanner = new Scanner(System.in);
    final int length = scanner.nextInt();
    final int[] numbers = new int[length];
    for (int idx = 0; idx < length; idx++) {
      numbers[idx] = scanner.nextInt();
    }

    final int result = maximumDifference(length, numbers);
    System.out.println(result);
  }

  public static int maximumDifference(final int N, final int[] A) {
    int maxDiff = 0;
    for (int currentIdx = 0; currentIdx < N; currentIdx++) {
      for (int otherIdx = 0; otherIdx < N; otherIdx++) {
        if (currentIdx == otherIdx) continue;

        final int diff = A[currentIdx] - A[otherIdx];
        maxDiff = maxDiff < diff ? diff : maxDiff;
      }
    }

    return maxDiff;
  }
}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz