#include<stdio.h>

int main(void)
{
	int mhi, mlo, np, t, f1, f2, n, m;
	scanf("%d",&n);
	for(f1 = 0; f1 < n; f1++)
	{
		mhi = 0; mlo = 0;
		scanf("%d",&m);
		for(f2 = 0; f2 < m; f2++)
		{
			scanf("%d",&np);
			if(f2 == 0)
				t = np;
			else
			{
				//降下
				if(t > np){
					if(mlo == 0 || mlo < t - np)
						mlo = t - np;
				}
				//登上
				else if(t < np){
					if(mhi == 0 || mhi < np - t)
						mhi = np - t;
				}
				t = np;
			}
			
		}
		printf("%d %d\n",mhi,mlo);
	}
	return 0;
}