stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.30937961432166x):
//#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.163937169504324x):
//#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.20448387785068x):
//#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.229529917052813x):
//#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.16226897079944x):
//#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.3093872050504185x):
//#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.202832751124437x):
//#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.226033670353097x):
//#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.308307487523848x):
//#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 minv, maxv = -2e9, a, n;

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

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

		scanf("%d", &a);

		maxv = max(maxv, a-minv);

		minv = min(minv, a);

	}



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



	return 0;

}
// Slower C++ solution:
#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;

    }

// Faster C++ solution for the same problem (measured speedup: 5.2016987211980314x):
//#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 minv, maxv = -2e9, a, n;

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

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

		scanf("%d", &a);

		maxv = max(maxv, a-minv);

		minv = min(minv, a);

	}



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



	return 0;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.30822236102114x):
//#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 minv, maxv = -2e9, a, n;

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

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

		scanf("%d", &a);

		maxv = max(maxv, a-minv);

		minv = min(minv, a);

	}



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



	return 0;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.162811617412143x):
//#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 minv, maxv = -2e9, a, n;

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

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

		scanf("%d", &a);

		maxv = max(maxv, a-minv);

		minv = min(minv, a);

	}



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



	return 0;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.203349488038187x):
//#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 minv, maxv = -2e9, a, n;

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

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

		scanf("%d", &a);

		maxv = max(maxv, a-minv);

		minv = min(minv, a);

	}



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



	return 0;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.22839006810693x):
//#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 minv, maxv = -2e9, a, n;

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

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

		scanf("%d", &a);

		maxv = max(maxv, a-minv);

		minv = min(minv, a);

	}



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



	return 0;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.161143782314421x):
//#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 minv, maxv = -2e9, a, n;

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

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

		scanf("%d", &a);

		maxv = max(maxv, a-minv);

		minv = min(minv, a);

	}



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



	return 0;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.308229950095393x):
//#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 minv, maxv = -2e9, a, n;

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

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

		scanf("%d", &a);

		maxv = max(maxv, a-minv);

		minv = min(minv, a);

	}



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



	return 0;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.2016987211980314x):
//#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 minv, maxv = -2e9, a, n;

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

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

		scanf("%d", &a);

		maxv = max(maxv, a-minv);

		minv = min(minv, a);

	}



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



	return 0;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.224894583462921x):
//#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 minv, maxv = -2e9, a, n;

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

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

		scanf("%d", &a);

		maxv = max(maxv, a-minv);

		minv = min(minv, a);

	}



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



	return 0;

}
// Slower C++ solution:
// -*- 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

// Faster C++ solution for the same problem (measured speedup: 5.2433698815041065x):
// -*- 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
// Slower C++ solution:
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-

// ALDS1_1-D: Maximum Profit



#include <algorithm>

#include <iostream>



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::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;

}



// eof

// Faster C++ solution for the same problem (measured speedup: 5.244281997835495x):
// -*- 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
// Slower C++ solution:


#include<iostream>

#include<algorithm>

using namespace std;

static const int MAX = 200000;

int main() {

	int R[MAX], n;

	cin >> n;

	for (int i = 0; i<n; i++)cin >> R[i];



	int maxv = -2000000000;

	int minv = R[0];



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

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

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

	}

	cout << maxv << endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.315697585491691x):
#include "stdio.h"

#include <math.h>

int main()

{

	int n,R,Min;

	int diff = (int)pow(10, 9)*-1-1;



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

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

		scanf("%d", &R);

		if (diff < R - Min) {

			diff = R - Min;

		}

		if (Min > R) {

			Min = R;

		}

	}

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

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

using namespace std;

static const int MAX = 200000;

int main() {

	int R[MAX], n;

	cin >> n;

	for (int i = 0; i<n; i++)cin >> R[i];



	int maxv = -2000000000;

	int minv = R[0];



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

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

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

	}

	cout << maxv << endl;

	return 0;

}




// Faster C++ solution for the same problem (measured speedup: 5.315697585491691x):
#include "stdio.h"

#include <math.h>

int main()

{

	int n,R,Min;

	int diff = (int)pow(10, 9)*-1-1;



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

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

		scanf("%d", &R);

		if (diff < R - Min) {

			diff = R - Min;

		}

		if (Min > R) {

			Min = R;

		}

	}

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

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

using namespace std;

static const int MAX = 200000;



int main() {

  int R[MAX], n;



  cin >> n;

  for ( int i = 0; i < n; i++ ) cin >> R[i];



  int maxv = -2000000000;  // 十分小さい値を初期値に設定

  int minv = R[0];



  for ( int i = 1; i < n; i++ ) {  // ここで毎回 R[i] を読み込めば、配列は不要

    maxv = max(maxv, R[i] - minv);  // 最大値を更新

    minv = min(minv, R[i]);  // ここまでの最小値を保持しておく

  }



  cout << maxv << endl;



  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.31314179961239x):
#include<cstdio>

using namespace std;



int main() {

  int n, Rt;

  int maxv = -2e9;

  int minv = 2e9;



  scanf("%d", &n);



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

    scanf("%d", &Rt);

    maxv = maxv > Rt-minv ? maxv : Rt-minv;

    minv = minv < Rt ? minv : Rt;

  }



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



  return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

using namespace std;



int main() {

  int n, Rt;

  int maxv = -2e9;

  int minv = 2e9;



  cin >> n;



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

    cin >> Rt;

    maxv = max(maxv, Rt - minv);

    minv = min(minv, Rt);

  }



  cout << maxv << endl;



  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.232788568400972x):
#include<cstdio>

using namespace std;



int main() {

  int n, Rt;

  int maxv = -2e9;

  int minv = 2e9;



  scanf("%d", &n);



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

    scanf("%d", &Rt);

    maxv = maxv > Rt-minv ? maxv : Rt-minv;

    minv = minv < Rt ? minv : Rt;

  }



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



  return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

using namespace std;

static const int MAX = 200000;



int main() {

  int R[MAX], n;



  cin >> n;

  for ( int i = 0; i < n; i++ ) cin >> R[i];



  int maxv = -2000000000;  // 十分小さい値を初期値に設定

  int minv = R[0];



  for ( int i = 1; i < n; i++ ) {  // ここで毎回 R[i] を読み込めば、配列は不要

    maxv = max(maxv, R[i] - minv);  // 最大値を更新

    minv = min(minv, R[i]);  // ここまでの最小値を保持しておく

  }



  cout << maxv << endl;



  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.31314179961239x):
#include<cstdio>



int main() {

  int n, Rt;

  int maxv = -2e9;

  int minv = 2e9;



  scanf("%d", &n);



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

    scanf("%d", &Rt);

    maxv = maxv > Rt-minv ? maxv : Rt-minv;

    minv = minv < Rt ? minv : Rt;

  }



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



  return 0;

}