Shahbaj Ansari has been working in the professional field since 2009, when they began as Floor Manager at a Department Store. In 2018, they moved to Traddle, where they currently serve as Database Manager.
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#include <ctime>
#include <climits>
const double Pi=acos(-1.0);
typedef long long LL;
#define Set(a, s) memset(a, s, sizeof (a))
#define Rd(r) freopen(r, "r", stdin)
#define Wt(w) freopen(w, "w", stdout)
using namespace std;
int main(){
int N;
cin>>N;
int arr[N];
int max=0;
int min=INT_MAX;
for(int i=0; i<N; i++){
cin>>arr[i];
if(arr[i]>max)
max=arr[i];
if(arr[i]<min)
min=arr[i];
}
int diff=max-min;
cout<<diff<<endl;
}
Sign up to view 0 direct reports
Get started