#include <cstdio>

int R[200005];

int main() {
	int n; scanf("%d", &n);
	scanf("%d", &R[0]);
	int min = R[0], ans = -2e9;
	for (int i = 1; i < n; ++i) {
		scanf("%d", &R[i]);
		if (R[i] - min > ans) ans = R[i] - min;
		if (R[i] < min) min = R[i];
	}
	printf("%d\n", ans);
}
