aboutsummaryrefslogtreecommitdiff
path: root/MinDiffInArray.cpp
blob: 5440d039fdc94583ced2ef8b41e7f3351306b5db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> res;
  for(auto &x : v){
    cin >> x;
  }
  sort(v.begin(), v.end());
  for(int i = 0; i < n - 1; i++){
    // 1 2 3 4 5 6 7
    res.push_back(abs(v[i] - v[i+1]));
  }
  cout << *min_element(res.begin(), res.end()) << endl;
  return 0;
}