#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n < 2) {
cout << 0 << '\n';
return 0;
}
int price;
cin >> price; // 第一天价格
int minPrice = price; // 历史最低
int maxProfit = 0; // 当前最大利润
for (int i = 1; i < n; ++i) {
cin >> price; // 边读边算
int profit = price - minPrice;
if (profit > maxProfit) maxProfit = profit;
if (price < minPrice) minPrice = price;
}
cout << maxProfit << '\n';
return 0;
}

京公网安备 11010502036488号