stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;



int ans[10000 + 5];



int main(){

	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

	

	int n;

	cin >> n;

	string s;

	cin >> s;

	for(int i = 1; i <= (int)s.size(); i++){

		int x = (int) s[i - 1];

		x -= 65;

		x += n;

		x %= 26;

		x += 65;

		ans[i] = x;

	}

	for(int i = 1; i <= (int)s.size(); i++)

		cout << (char) ans[i];

	

	return 0;

}




// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int n;

	scanf("%d", &n);

	char inp[10001];

	scanf("%s", inp);



	for(int i=0; inp[i]!='\0';i++){

		if(inp[i]+n>'Z'){

			inp[i]=inp[i]+n-26;

		}else{

			inp[i]+=n;

		}

	}

	printf("%s", inp);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
/******************************************

* AUTHOR : RAJAGOPALAN *

* NICK : ARNO *

* INSTITUTION : VIT *

******************************************/

#include <bits/stdc++.h>

#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long

#define ull unsigned long long

#define pb push_back

#define mp make_pair

#define all(x) (x).begin(),(x).end()

#define alli(a, n, k) (a+k),(a+n+k)

#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)

#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)

#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define eps 1e-6

#define pi 3.141592653589793

using namespace std;

using namespace __gnu_pbds;



template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}

typedef vector<int> VII;

typedef vector<ll> VLL;

typedef pair<int, int> PII;

typedef vector< pair<int, int> > VPII;

typedef vector< pair<int, PII > > VPPI;

const int MOD = 1e9 + 7;

const int INF = 1e9;



inline ll modulo(ll a, ll m)

{

    return (a % m + m) % m;

}



inline ll modInverse(ll a, ll m)

{

    assert(__gcd(a, m) == 1);

    ll m0 = m;

    ll y = 0, x = 1;



    if (m == 1)

        return 0;



    while (a > 1)

    {

        ll q = a / m;

        ll t = m;



        m = a % m, a = t;

        t = y;



        y = x - q * y;

        x = t;

    }



    if (x < 0)

        x += m0;



    return x;

}



inline ll modPow(ll x, ll y, ll m)

{ //x^y % m

    if (y == 0)

        return 1LL;

    else if (y == 1)

        return x;

    else

    {

        ll ans = modPow(x, y / 2, m) % m;

        if (y & 1)

        {

            return (((ans * ans) % m) * x) % m;

        }

        else

        {

            return (ans * ans) % m;

        }

    }

}



int main(int argc, char* argv[])

{

    ios::sync_with_stdio(false);

    cin.tie(NULL);

    int n;

    string s;

    cin>>n>>s;

    for(int i=0;i<s.size();++i)

    {

        s[i]=(s[i]-'A'+n)%26 +'A';

    }

    cout<<s;

    return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int n;

	scanf("%d", &n);

	char inp[10001];

	scanf("%s", inp);



	for(int i=0; inp[i]!='\0';i++){

		if(inp[i]+n>'Z'){

			inp[i]=inp[i]+n-26;

		}else{

			inp[i]+=n;

		}

	}

	printf("%s", inp);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

	int n,i,cap;

	string s;

	cin>>n;

	cin>>s;

	for(i=0;i<s.size();i++){

		cap=s[i]+n;

		if(cap<=90){

			s[i]=cap;

		}

		else if(cap>90){

			s[i]=cap-26;

		}

	}

	cout<<s<<endl;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int n;

	scanf("%d", &n);

	char inp[10001];

	scanf("%s", inp);



	for(int i=0; inp[i]!='\0';i++){

		if(inp[i]+n>'Z'){

			inp[i]=inp[i]+n-26;

		}else{

			inp[i]+=n;

		}

	}

	printf("%s", inp);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
/* ANTHOR KUMAR DAS

KUET ECE 2K18*/

#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define sc(a) scanf("%d",&a)

#define sc1(n) scanf("%lld",&n)

#define sc2(b,c) scanf("%lld%lld",&b,&c)

#define f(a,b) for(a=0;a<b;a++)

#define pb(a) push_back(a)

#define br break

int main()

{

    int n,i,k;

    char j;

    cin>>n;

    char s[90000];

    scanf("%s",s);

    k=strlen(s);

    for(i=0;i<k;i++)

    {

        if(s[i]+n<=90)

        {

            j=s[i]+n;

            cout<<j;

        }

        else{

            j=s[i]+n-26;

            cout<<j;

        }

    }



    return 0;

}




// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int n;

	scanf("%d", &n);

	char inp[10001];

	scanf("%s", inp);



	for(int i=0; inp[i]!='\0';i++){

		if(inp[i]+n>'Z'){

			inp[i]=inp[i]+n-26;

		}else{

			inp[i]+=n;

		}

	}

	printf("%s", inp);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

///                    BISMILLAHIR RAHMANIR RAHIM



int main()

{

   int n;

   cin>>n;

   string s;

   cin>>s;

   int l=s.length();

   for(int i=0;i<l;i++){

    int r=s[i]+n;

    if(r>90)

        r=r-26;

    printf("%c",(r));

   }

   cout<<endl;



}







/// A L H A M D U L I L L A H


// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int n;

	scanf("%d", &n);

	char inp[10001];

	scanf("%s", inp);



	for(int i=0; inp[i]!='\0';i++){

		if(inp[i]+n>'Z'){

			inp[i]=inp[i]+n-26;

		}else{

			inp[i]+=n;

		}

	}

	printf("%s", inp);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;



#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define tt int t; cin>>t; while(t--)

#define nl cout<<"\n";

#define sp cout<<" ";

#define rep(i, a, b) for(long long i=a; i<b; i++)



const int INF = 1e9 + 7;

const int MOD = 1e9 + 7;

double PI = 4*atan(1);



int main()

{

    optimize();



    int n;

    string s;

    cin>> n>> s;



    for( int i=0; i<s.size(); i++)

    {

        s[i]=( s[i] + n <= 'Z' ? s[i]+ n : s[i]+ n-26);

    }



    cout << s << '\n';



    return 0;

}






// Optimized solution to the same problem (faster):




#include<stdio.h>

#include<string.h>

int main()

{

    int n,j,c;

    scanf("%d",&n);

    char s[10000];

    scanf("%s",&s);

    j=strlen(s);

    for(int i=0;i<j;i++){

        c = s[i] - 'A';

        s[i] = 'A' + (c+n)%26;



}

printf("%s",s);

return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <bits/stdc++.h>

using namespace std;

int n,a;

string s;

char c;

int main()

{

    cin >> n >> s;

    for(int i=0;i<s.length();i++){

        if(static_cast<char>(s[i] + n)<'A'||static_cast<char>(s[i] + n)>'Z') cout << static_cast<char>(s[i] -26+ n);

       else cout << static_cast<char>(s[i] + n);

    }

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>



int main() {

	int n;

	char s[10005];



	scanf("%d", &n);

	scanf("%s", s);



	for(int i = 0; s[i] != '\0'; i++) {

		s[i] = 'A' + (s[i] - 'A' + n) % 26;

	}



	puts(s);



	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>



using namespace std;



int main(int argc, char const *argv[])

{

    int n;

    string s, s1 = "";

    cin >> n >> s;

    for (char i : s)

    {

        int p1, p2, t;

        t = n;

        p1 = (int)i;

        p2 = min(90, p1 + t);

        t -= (p2 - p1);

        if (t > 0)

            p2 = 65 + t - 1;

        s1.push_back((char(p2)));

    }

    cout << s1;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>



int main() {

	int n;

	char s[10005];



	scanf("%d", &n);

	scanf("%s", s);



	for(int i = 0; s[i] != '\0'; i++) {

		s[i] = 'A' + (s[i] - 'A' + n) % 26;

	}



	puts(s);



	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):


#include<vector>

#include<iostream>



using namespace std;



int main(){

    int n; 

    cin>>n;

    string s;

    cin>>s;

    for( int i =0; i < s.size(); i++)

    {

        int temp = s[i] - 65;

        temp = (temp + n ) %26;

        temp += 65;

        s[i] = temp;

    }

    cout<<s;





  



    return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>



int main() {

	int n;

	char s[10005];



	scanf("%d", &n);

	scanf("%s", s);



	for(int i = 0; s[i] != '\0'; i++) {

		s[i] = 'A' + (s[i] - 'A' + n) % 26;

	}



	puts(s);



	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>



using namespace std;



int main(){

    string s,c;

    int n,i,j,k;

    cin>>n>>s;

    int len=s.size();

    for(i=0;i<len;i++){

        if(s[i]+n>'Z'){cout<<char(s[i]+n-26);}

        else {cout<<char(s[i]+n);}

    }



    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>



int main() {

	int n;

	char s[10005];



	scanf("%d", &n);

	scanf("%s", s);



	for(int i = 0; s[i] != '\0'; i++) {

		s[i] = 'A' + (s[i] - 'A' + n) % 26;

	}



	puts(s);



	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int main(){



    int n;

    cin >> n;



    string s;

    cin >> s;



    for(int i=0;i<s.length();i++){

        s[i] = (s[i] - 'A' + n) % 26 + 'A';

    }



    cout << s << endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>



int main() {

	int n;

	char s[10005];



	scanf("%d", &n);

	scanf("%s", s);



	for(int i = 0; s[i] != '\0'; i++) {

		s[i] = 'A' + (s[i] - 'A' + n) % 26;

	}



	puts(s);



	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<stdio.h>

#define NMAX 200000

#define RMAX 1000000000

int main()

{

	int a[NMAX] = {0};

	int n = 0;

	scanf("%d", &n);

	int maxv = 0;

	int minv = 0;

	for(int i = 0 ; i < n ; i++)

	{

		scanf("%d", &a[i]);

	}

	minv = a[0];

	maxv = a[1] - a[0];

	for(int i = 1 ; i < n ; i++)

	{

		maxv = (maxv > a[i] - minv)?maxv:(a[i] - minv);

		minv = (minv < a[i])?minv:a[i];

	}

	printf("%d\n", maxv);

	return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#define NMAX 200000

#define RMAX 1000000000

int main()

{

	int a[NMAX] = {0};

	int temp = 0;

	int n = 0;

	scanf("%d", &n);

	int maxv = 0;

	int minv = 0;

	for(int i = 0 ; i < n ; i++)

	{

		scanf("%d", &temp);

		if(i == 0)

		{

			minv = temp;

		}

		else if(i == 1)

		{

			maxv = temp - minv;

			minv = (minv < temp)?minv:temp;

		}

		else

		{

			maxv = (maxv > temp - minv)?maxv:(temp-minv);

			minv = (minv < temp)?minv:temp;

		}

	}

	printf("%d\n", maxv);

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <stdio.h>

#include <algorithm>

using namespace std;



int main()

{

    long int arr[200010]={0};

    long int arrmin;

    long int dmax;

    int n=0;

    scanf("%d",&n);

    for(int i=0;i<n;i++){

        scanf("%ld",&arr[i]);

        if(i==0){

            arrmin=arr[0];

            continue;

        } 

        if(i==1) dmax=arr[1]-arr[0];

        if(arr[i-1]<=arr[i]){

            dmax=max(arr[i]-arrmin,dmax);

        }else{

            arrmin=min(arr[i],arrmin);

        }        

    } 

    printf("%ld\n",dmax);





    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <algorithm>

using namespace std;



int main()

{

    int minv;

    int dmax=-2000000000;

    int var;

    int n;

    scanf("%d",&n);

    scanf("%d",&minv);

    for(int i=1;i<n;i++){

        scanf("%d",&var);

        dmax=max(var-minv,dmax);

        minv=min(var,minv);

    } 

    printf("%d\n",dmax);





    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

const int MAX = 200005;

using namespace std;

int main()

{

    int a[MAX];

    int n;

    cin>>n;

    for(int i=0;i<n;i++)

    {

        cin>>a[i];

    }

    int maxv = a[1]-a[0];

    int mina = a[0];

    for(int i=1;i<n;i++)

    {

        maxv = max(maxv,a[i]-mina);

        mina = min(a[i],mina);

    }

    cout<<maxv<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>

using namespace std;

const int MAX=200001;

int a[MAX];

int main()

{



  int n;

  scanf("%d",&n);

  for(int i=0;i<n;i++)

    scanf("%d",&a[i]);

    int maxv=-2000000000;

    int minv=a[0];

    for(int i=1;i<n;i++)

    {

        maxv=max(maxv,a[i]-minv);

        minv=min(minv,a[i]);

    }

    printf("%d\n",maxv);

    return 0;



}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<stdio.h>

#include<string.h>

#include<iostream>

#include<algorithm>

#define maxn 200010

int a[maxn];

using namespace std;



int main()

{

    int n,k,mavx=-2000000000,mivn;

    scanf("%d",&n);

    for(int i=1;i<=n;i++)

    {

        scanf("%d",&a[i]);

    }



    mivn=a[1];



    for(int i=2;i<=n;i++)

    {

        mavx=max(a[i]-mivn,mavx);

        mivn=min(a[i],mivn);

    }



    printf("%d\n",mavx);

    return 0;

    }

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>

using namespace std;

const int MAX=200001;

int a[MAX];

int main()

{



  int n;

  scanf("%d",&n);

  for(int i=0;i<n;i++)

    scanf("%d",&a[i]);

    int maxv=-2000000000;

    int minv=a[0];

    for(int i=1;i<n;i++)

    {

        maxv=max(maxv,a[i]-minv);

        minv=min(minv,a[i]);

    }

    printf("%d\n",maxv);

    return 0;



}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>



using namespace std;



int main() {

  int n, R[200000 + 5];

  cin >> n;

  for (int i = 0; i < n; i++) {

    cin >> R[i];

  }

  int ans = R[1] - R[0];

  int minv = min(R[0], R[1]);

  for (int i = 2; i < n; i++) {

    ans = max(ans, R[i] - minv);

    minv = min(minv, R[i]);

  }

  cout << ans << endl;

  return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>

using namespace std;

const int MAX=200001;

int a[MAX];

int main()

{



  int n;

  scanf("%d",&n);

  for(int i=0;i<n;i++)

    scanf("%d",&a[i]);

    int maxv=-2000000000;

    int minv=a[0];

    for(int i=1;i<n;i++)

    {

        maxv=max(maxv,a[i]-minv);

        minv=min(minv,a[i]);

    }

    printf("%d\n",maxv);

    return 0;



}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

const int INF = 0x3f3f3f3f;

int main()

{

	int n,num;

	while(~scanf("%d",&n)) {

		scanf("%d",&num);

		int maxx=-INF,minn=num;

		for (int i=1;i<n;i++) {

			scanf("%d",&num);

			maxx=max(maxx,num-minn);

			minn=min(minn,num);

		}

		printf("%d\n",maxx);

	}	

 	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>

using namespace std;

const int MAX=200001;

int a[MAX];

int main()

{



  int n;

  scanf("%d",&n);

  for(int i=0;i<n;i++)

    scanf("%d",&a[i]);

    int maxv=-2000000000;

    int minv=a[0];

    for(int i=1;i<n;i++)

    {

        maxv=max(maxv,a[i]-minv);

        minv=min(minv,a[i]);

    }

    printf("%d\n",maxv);

    return 0;



}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<string>

#include<cctype>

#include<iostream>

#include<cstdio>

#include<cmath>

#include<queue>

using namespace std;

#define inf 0x3f3f3f3f

const int maxn = 200000 + 8;



int a[maxn];

int n;



int main()

{

    scanf("%d",&n);

    for(int i = 0; i < n; ++i){

        scanf("%d",&a[i]);

    }



    int minv = a[0];

    int maxv = -2000000000;

    for(int i = 1; i < n; ++i){

        maxv = max(maxv,a[i] - minv);

        minv = min(minv,a[i]);

    }

    printf("%d\n",maxv);

    return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>

using namespace std;

const int MAX=200001;

int a[MAX];

int main()

{



  int n;

  scanf("%d",&n);

  for(int i=0;i<n;i++)

    scanf("%d",&a[i]);

    int maxv=-2000000000;

    int minv=a[0];

    for(int i=1;i<n;i++)

    {

        maxv=max(maxv,a[i]-minv);

        minv=min(minv,a[i]);

    }

    printf("%d\n",maxv);

    return 0;



}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int main()

{

	int Min = INT_MAX;

	int Max = -INT_MAX;

	

	int n,temp;

	cin >> n;

	for(int i = 1;i <= n;i ++)

	{

		cin >> temp;

		if(i != 1) Max = max(temp - Min, Max);

		Min = min(Min,temp);

	}

	

	cout << Max <<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>

using namespace std;

const int MAX=200001;

int a[MAX];

int main()

{



  int n;

  scanf("%d",&n);

  for(int i=0;i<n;i++)

    scanf("%d",&a[i]);

    int maxv=-2000000000;

    int minv=a[0];

    for(int i=1;i<n;i++)

    {

        maxv=max(maxv,a[i]-minv);

        minv=min(minv,a[i]);

    }

    printf("%d\n",maxv);

    return 0;



}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<iostream>

using namespace std;

int sun[1000000];



int main()

{

	int n;

	scanf("%d",&n);

	for(int i=0;i<n;i++)

	{

		scanf("%d",&sun[i]);

	}int maxv=-2000000000;

	 int minv=sun[0];

	for(int i=1;i<n;i++)

	{

		maxv=max(maxv,sun[i]-minv);

		minv=min(minv,sun[i]);

	}

	printf("%d\n",maxv);

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>

using namespace std;

const int MAX=200001;

int a[MAX];

int main()

{



  int n;

  scanf("%d",&n);

  for(int i=0;i<n;i++)

    scanf("%d",&a[i]);

    int maxv=-2000000000;

    int minv=a[0];

    for(int i=1;i<n;i++)

    {

        maxv=max(maxv,a[i]-minv);

        minv=min(minv,a[i]);

    }

    printf("%d\n",maxv);

    return 0;



}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<algorithm>

using namespace std;

int main()

{

    int a[220000];

    int n;

    cin>>n;

    for(int i=0;i<n;i++)

    {

        cin>>a[i];

    }

     int maxa=-9999999999;

     int maxq=a[0];

     for(int i=1;i<n;i++)

     {



        maxa=max(maxa,a[i]-maxq);

        maxq=min(maxq,a[i]);

     }

     cout<<maxa<<endl;

     return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>

using namespace std;

const int MAX=200001;

int a[MAX];

int main()

{



  int n;

  scanf("%d",&n);

  for(int i=0;i<n;i++)

    scanf("%d",&a[i]);

    int maxv=-2000000000;

    int minv=a[0];

    for(int i=1;i<n;i++)

    {

        maxv=max(maxv,a[i]-minv);

        minv=min(minv,a[i]);

    }

    printf("%d\n",maxv);

    return 0;



}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

using namespace std;

int a[200010];

int main()

{

    int n,minh,maxh=-2000000000;

    scanf("%d",&n);

    for(int i=0;i<n;i++)

        scanf("%d",&a[i]);

    minh=a[0];

    for(int i=1;i<n;i++)

    {

        maxh=max(maxh,a[i]-minh);

        minh=min(minh,a[i]);

    }

    printf("%d\n",maxh);

    return 0;

}

// Optimized solution to the same problem (faster):
//#define LOCAL



#include <cstdio>

#include <algorithm>

using namespace std;



int main()

{

	#ifdef LOCAL

		freopen("E:\\Temp\\input.txt", "r", stdin);

		freopen("E:\\Temp\\output.txt", "w", stdout);

	#endif



	int a, b, n, minv, maxv = -2e9;

	scanf("%d%d", &n, &b); 

	--n; minv = b;

	while(n--) {

		scanf("%d", &a);

		maxv = max(maxv, a-minv);

		minv = min(minv, a);

		//printf("minv=%d, maxv=%d\n", minv, maxv);

	}



	printf("%d\n", maxv);



	return 0;

}



	

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

using namespace std;

int  main(){

	long n,minv=9999999999,maxv=-9999999999;

	cin>>n;

	for(long i=0;i<n;i++) {

		long r;

		cin>>r;

		maxv=max(maxv,r-minv);

		minv=min(minv,r);

	

		

	}

	cout<<maxv<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
//#define LOCAL



#include <cstdio>

#include <algorithm>

using namespace std;



int main()

{

	#ifdef LOCAL

		freopen("E:\\Temp\\input.txt", "r", stdin);

		freopen("E:\\Temp\\output.txt", "w", stdout);

	#endif



	int a, b, n, minv, maxv = -2e9;

	scanf("%d%d", &n, &b); 

	--n; minv = b;

	while(n--) {

		scanf("%d", &a);

		maxv = max(maxv, a-minv);

		minv = min(minv, a);

		//printf("minv=%d, maxv=%d\n", minv, maxv);

	}



	printf("%d\n", maxv);



	return 0;

}



	

// Fastest known solution for this problem:
// Original C++ solution (slower):
// -*- mode:c++; coding:utf-8; indent-tabs-mode:nil; -*-

// ALDS1_1-A



#include <algorithm>

#include <iostream>



int max_profit(int const rs[], const unsigned int n) {

  int r0 = rs[0];

  int r1 = rs[1];

  int cur_p = r1 - r0;

  int max_p = cur_p;

  int min_r =  std::min(r0, r1);



  for (unsigned int i = 2; i < n; ++i) {

    const int r = rs[i];

    cur_p = r - min_r;

    max_p = std::max(max_p, cur_p);

    min_r = std::min(min_r, r);

  }



  return max_p;

}



int main(void) {

  unsigned int n;

  std::cin >> n;

  int rs[n];

  for (unsigned int i = 0; i < n; ++i) {

    std::cin >> rs[i];

  }



  const int max_p = max_profit(rs, n);

  std::cout << max_p << std::endl;



  return 0;

}

// end

// Optimized solution to the same problem (faster):
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-

// ALDS1_1-D: Maximum Profit



#include <algorithm>

#include <cstdio>



static int max_profit(int const rs[], const unsigned int n)

{

  auto r0 = rs[0], r1 = rs[1];



  auto cur_p = r1 - r0;

  auto max_p = cur_p;

  auto min_r = std::min(r0, r1);



  for (auto i = 2u; i < n; ++i) {

    const auto r = rs[i];

    cur_p = r - min_r;

    max_p = std::max(max_p, cur_p);

    min_r = std::min(min_r, r);

  }



  return max_p;

}



int main()

{

  unsigned int n;

  std::scanf("%d", &n);

  int rs[n];

  for (unsigned int i = 0; i < n; ++i) {

    std::scanf("%d", &rs[i]);

  }



  const int max_p = max_profit(rs, n);

  std::printf("%d\n", max_p);

}



// eof

// Fastest known solution for this problem: