# [Codeforces496A] Minimum Difficulty

## 描述 Description

Mike is trying rock climbing but he is awful at it.

There are n holds on the wall, i-th hold is at height ai off the ground. Besides, let the sequence ai increase, that is, ai

## 输入格式 InputFormat

The first line contains a single integer n (3 ≤ n ≤ 100) — the number of holds.

The next line contains n space-separated integers ai (1 ≤ ai ≤ 1000), where ai is the height where the hold number i hangs. The sequence ai is increasing (i.e. each element except for the first one is strictly larger than the previous one).

## 输出格式 OutputFormat

Print a single number — the minimum difficulty of the track after removing a single hold.

5
1 2 3 7 8

4

Codeforces 496A

## 代码 Code

#include <stdio.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
const int inf=0x7fffffff/27.11;
const int maxn=105;
int i,j,t,n,m,l,r,k,z,y,x;
int a[maxn];
int ans;
int main()
{
scanf("%d",&n);
for (i=1;i<=n;i++) scanf("%d",&a[i]);
ans=inf;
for (i=2;i<n;i++)
{
t=0;
for (j=1;j<n;j++) if (i!=j) t=max(t,(j+1==i)?(a[j+2]-a[j]):(a[j+1]-a[j]));
ans=min(ans,t);
}
printf("%d\n",ans);
return 0;
}