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;
  }
} import java.util.Scanner; Scanner java.util 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;
  }
} 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);
  } main {
    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);
  } final Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) final int length = scanner.nextInt(); length scanner.nextInt() scanner.nextInt scanner final int[] numbers = new int[length]; numbers new int[length] length for (int idx = 0; idx < length; idx++) {
      numbers[idx] = scanner.nextInt();
    } int idx = 0; int idx = 0; idx 0 idx < length idx length idx++ idx++ idx {
      numbers[idx] = scanner.nextInt();
    } {
      numbers[idx] = scanner.nextInt();
    } numbers[idx] = scanner.nextInt() numbers[idx] numbers idx scanner.nextInt() scanner.nextInt scanner final int result = maximumDifference(length, numbers); result maximumDifference(length, numbers) maximumDifference length numbers System.out.println(result) System.out.println System.out System System.out result String ...args args 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;
  } maximumDifference {
    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;
  } int maxDiff = 0; 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;
      }
    } int currentIdx = 0; int currentIdx = 0; currentIdx 0 currentIdx < N currentIdx N currentIdx++ currentIdx++ currentIdx {
      for (int otherIdx = 0; otherIdx < N; otherIdx++) {
        if (currentIdx == otherIdx) continue;

        final int diff = A[currentIdx] - A[otherIdx];
        maxDiff = maxDiff < diff ? diff : maxDiff;
      }
    } {
      for (int otherIdx = 0; otherIdx < N; otherIdx++) {
        if (currentIdx == otherIdx) continue;

        final int diff = A[currentIdx] - A[otherIdx];
        maxDiff = maxDiff < diff ? diff : maxDiff;
      }
    } for (int otherIdx = 0; otherIdx < N; otherIdx++) {
        if (currentIdx == otherIdx) continue;

        final int diff = A[currentIdx] - A[otherIdx];
        maxDiff = maxDiff < diff ? diff : maxDiff;
      } int otherIdx = 0; int otherIdx = 0; otherIdx 0 otherIdx < N otherIdx N otherIdx++ otherIdx++ otherIdx {
        if (currentIdx == otherIdx) continue;

        final int diff = A[currentIdx] - A[otherIdx];
        maxDiff = maxDiff < diff ? diff : maxDiff;
      } {
        if (currentIdx == otherIdx) continue;

        final int diff = A[currentIdx] - A[otherIdx];
        maxDiff = maxDiff < diff ? diff : maxDiff;
      } if (currentIdx == otherIdx) continue; currentIdx == otherIdx currentIdx otherIdx continue; final int diff = A[currentIdx] - A[otherIdx]; diff A[currentIdx] - A[otherIdx] A[currentIdx] A currentIdx A[otherIdx] A otherIdx maxDiff = maxDiff < diff ? diff : maxDiff maxDiff maxDiff < diff ? diff : maxDiff maxDiff < diff maxDiff diff diff maxDiff return maxDiff; maxDiff final int N N final int[] A A 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;
  }
} 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;
  }
} Main
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;
  }
}
