Ngôn ngữ: C++
#include <bits/stdc++.h>
using namespace std;
long long n;
long long minx=LLONG_MAX;
long long a[100000];
int main()
{
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
sort(a+1,a+n+1);
for(int i=2;i<=n;i++){
minx=min(minx,a[i]-a[i-1]);
}
cout<<minx;
return 0;
}
Program HOC24;
uses crt;
var i,n: integer;
a: array[1..1000] of integer;
max1, max2: integer;
begin
clrscr;
readln(n);
for i:=1 to n do
begin
read(a[i]);
end;
readln;
max1:=a[1]; max2:=a[1];
for i:=2 to n do
begin
if max1>a[i] then max1:=a[i];
if max2<a[i] then max2:=a[i];
end;
for i:=2 to n do if (a[i]<>max1) and (max2>a[i]) then max2:=a[i];
write(max2-max1);
readln;
end