#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n;
    cin >> n;
    while (n--) {
        int t; cin >> t;
        vector<int> vec;
        for (int i = 0; i < t; ++i) {
            int num;
            cin >> num;
            vec.push_back(num);
        }
        sort(vec.begin(), vec.end());
        int min_dis = 1001;
        for (int i = 1; i < t; ++i) {
            if (vec[i] - vec[i-1] < min_dis) min_dis = vec[i] - vec[i-1];
        }
        cout << min_dis << endl;
    }
return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	int t;
	cin>>t;
	int n;
	int arr[50];
	int m;
	for(int i=0;i<t;i++){
		cin>>n;
		for(int j=0;j<n;j++){
			cin>>arr[j];
		}
		sort(arr,arr+n);
		m=arr[1]-arr[0];
		for(int j=1;j<n-1;j++){
			if(arr[j+1]-arr[j]<m){
				m=arr[j+1]-arr[j];
			}
		}
		cout<<m<<"\n";
	}
}


#include<iostream>
#include<string>
#include<bits/stdc++.h>
using namespace std;

int main(){
	int t;
	cin>>t;
	int n;
	int arr[50];
	int m;
	for(int i=0;i<t;i++){
		cin>>n;
		for(int j=0;j<n;j++){
			cin>>arr[j];
		}
		sort(arr,arr+n);
		m=arr[1]-arr[0];
		for(int j=1;j<n-1;j++){
			if(arr[j+1]-arr[j]<m){
				m=arr[j+1]-arr[j];
			}
		}
		cout<<m<<"\n";
	}
}


// zebra1.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include "pch.h"
#include <iostream>
using namespace std;

int main()
{
	int cs;
	int num[1000];
	int str[1000][50];
	int i;
	int j;
	int d[1000];
	int k;

	cin >> cs;
	for (k = 0; k < cs; k++) {
		cin >> num[k];
		for (i = 0; i < num[k]; i++) {
			cin >> str[k][i];
		}
		d[k] = abs(str[k][1] - str[k][0]);
		for (i = 0; i < num[k] - 1; i++) {
			for (j = i + 1; j < num[k]; j++) {
				if (d[k] > abs(str[k][i] - str[k][j])) {
					d[k] = abs(str[k][i] - str[k][j]);
				}
			}
		}
	}
	for (i = 0; i < cs; i++) {
		cout <<"\n"<< d[i];
	}
}

// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单

// 入门提示:
//   1. 使用解决方案资源管理器窗口添加/管理文件
//   2. 使用团队资源管理器窗口连接到源代码管理
//   3. 使用输出窗口查看生成输出和其他消息
//   4. 使用错误列表窗口查看错误
//   5. 转到“项目”>“添加新项”以创建新的代码文件，或转到“项目”>“添加现有项”以将现有代码文件添加到项目
//   6. 将来，若要再次打开此项目，请转到“文件”>“打开”>“项目”并选择 .sln 文件


#include <iostream>
using namespace std;

int main()
{
	int cs;
	int num[1000];
	int str[1000][50];
	int i;
	int j;
	int d[1000];
	int k;

	cin >> cs;
	for (k = 0; k < cs; k++) {
		cin >> num[k];
		for (i = 0; i < num[k]; i++) {
			cin >> str[k][i];
		}
		d[k] = abs(str[k][1] - str[k][0]);
		for (i = 0; i < num[k] - 1; i++) {
			for (j = i + 1; j < num[k]; j++) {
				if (d[k] > abs(str[k][i] - str[k][j])) {
					d[k] = abs(str[k][i] - str[k][j]);
				}
			}
		}
	}
	for (i = 0; i < cs; i++) {
		cout <<"\n"<< d[i];
	}
}


// zebra1.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

//#include "pch.h"
#include <iostream>
using namespace std;

int main()
{
	int cs;
	int num[1000];
	int str[1000][50];
	int i;
	int j;
	int d[1000];
	int k;

	cin >> cs;
	for (k = 0; k < cs; k++) {
		cin >> num[k];
		for (i = 0; i < num[k]; i++) {
			cin >> str[k][i];
		}
		d[k] = abs(str[k][1] - str[k][0]);
		for (i = 0; i < num[k] - 1; i++) {
			for (j = i + 1; j < num[k]; j++) {
				if (d[k] > abs(str[k][i] - str[k][j])) {
					d[k] = abs(str[k][i] - str[k][j]);
				}
			}
		}
	}
	for (i = 0; i < cs; i++) {
		cout <<"\n"<< d[i];
	}
}

// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单

// 入门提示:
//   1. 使用解决方案资源管理器窗口添加/管理文件
//   2. 使用团队资源管理器窗口连接到源代码管理
//   3. 使用输出窗口查看生成输出和其他消息
//   4. 使用错误列表窗口查看错误
//   5. 转到“项目”>“添加新项”以创建新的代码文件，或转到“项目”>“添加现有项”以将现有代码文件添加到项目
//   6. 将来，若要再次打开此项目，请转到“文件”>“打开”>“项目”并选择 .sln 文件


#include<iostream>
#include<cstring>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {

   int t,in;
   cin >> t;

   for (int i = 0; i < t; i++)
	   {
	   vector <int> arr,arr_min; int n,count=0;bool flag = true;
	   cin >> n;
	   for (int m = 0; m < n; m++)
		   {cin>>in;arr.push_back(in);}

	   for (int j = 0; j < arr.size(); j++)
		   for (int k = j+1; k < arr.size(); k++)
			   arr_min.push_back( abs(arr[j]-arr[k]) );

	   cout << *min_element(arr_min.begin(), arr_min.end()) << endl;

	   }

   }


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main ()
{
	int nums_of_tests;
	cin >> nums_of_tests;
	for (int i = 0; i < nums_of_tests; i++)
	{
		int sportmens;
		cin >> sportmens;
		vector <int> full_of_strenght;
		for (int j = 0; j < sportmens; j++)
		{
			int a;
			cin >> a;
			full_of_strenght.push_back(a);

		}
		sort(full_of_strenght.begin(), full_of_strenght.end());
		int k = 0;
		k = full_of_strenght[sportmens - 1] - full_of_strenght[sportmens - 2];
		for (int j = sportmens - 2; j >= 1; j--)
		{
			int o = full_of_strenght[j] - full_of_strenght[j - 1];
			if (k > o)
			{
				k = o;
			}
		}
		cout << k << endl;
	}
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main ()
{
	int nums_of_tests;
	cin >> nums_of_tests;
	for (int i = 0; i < nums_of_tests; i++)
	{
		int sportmens;
		cin >> sportmens;
		vector <int> full_of_strenght;
		for (int j = 0; j < sportmens; j++)
		{
			int a;
			cin >> a;
			full_of_strenght.push_back(a);

		}
		sort(full_of_strenght.begin(), full_of_strenght.end());
		int o = 0, k = 0, p = 0;
		k = full_of_strenght[sportmens - 1] - full_of_strenght[sportmens - 2];
		for (int j = sportmens - 1; j > 1; j--)
		{
			o = full_of_strenght[j] - full_of_strenght[j - 1];
			if (k > o)
			{
				k = o;
				p = j;
			}
		}
		cout << k << endl;
	}
	return 0;
}


#include "stdlib.h"
#include <iostream>

using namespace std;

int comp(const void* a, const void* b)
{
	return (*(int*)a - *(int*)b);
}

int main() {
	int t, n, min, temp;
	int* mas;

	cin >> t;

	while (t-- > 0) {
		cin >> n;
		mas = new int[n];
		for (int i = 0; i < n; i++)
			cin >> mas[i];

		qsort(mas, n, sizeof(int), comp);

		min = mas[1] - mas[0];
		for (int i = 1; i < n - 1; i++)
		{
			temp = mas[i + 1] - mas[i];
			if (temp < min) min = temp;
		}

		cout << min << endl;
	}

	return 0;
}


#include "stdlib.h"
#include <iostream>

using namespace std;

int comp(const void* a, const void* b)
{
	return (*(int*)a - *(int*)b);
}

int main() {
	int t, n, min, temp;
	int* mas;

	cin >> t;

	while (t-- > 0) {
		cin >> n;
		mas = new int[n];
		for (int i = 0; i < n; i++)
			cin >> mas[i];

		qsort(mas, n, sizeof(int), comp);

		min = (mas[1] - mas[0]);
		for (int i = 1; i < n - 1; i++)
		{
			temp = mas[i + 1] - mas[i];
			if (temp < min) min = temp;
		}

		cout << min << endl;
	}

	return 0;
}


#include "stdlib.h"
#include <iostream>

using namespace std;

int comp(const void* a, const void* b)
{
	return (*(int*)a - *(int*)b);
}

int main() {
	int t, n, min;
	int* mas;

	cin >> t;

	while (t-- > 0) {
		cin >> n;
		mas = new int[n];
		for (int i = 0; i < n; i++)
			cin >> mas[i];

		qsort(mas, n, sizeof(int), comp);

		min = 0;
		for (int i = 1; i < n - 1; i++)
		{
			if (mas[i + 1] - mas[i] < mas[min + 1] - mas[min]) min = i;
		}

		cout << mas[min + 1] - mas[min] << endl;
	}

	return 0;
}


	//DPCoded
	//

#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef set<int> si;
typedef set<string> ss;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef pair<int, int> ii;

	//#define FILEINOUT
#ifdef FILEINOUT
ifstream In("Input.txt");
ofstream Out("Output.txt");
#else
#define In cin
#define Out cout
#endif

int main() {
	int q;
	In >> q;
	while (q--) {
		int n;
		In >> n;
		vi v;
		for (int i = 0; i < n; i++) {
			int t;
			In >> t;
			v.push_back(t);
		}

		sort(v.begin(), v.end());

		int mind = 100000;
		for (int i = 1; i < n; i++) {
			mind = min(mind, v[i] - v[i - 1]);
		}

		Out << mind << endl;

	}
	return 0;
}


	//DPCoded
	//

#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef set<int> si;
typedef set<string> ss;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef pair<int, int> ii;

	//#define FILEINOUT
#ifdef FILEINOUT
ifstream In("Input.txt");
ofstream Out("Output.txt");
#else
#define In cin
#define Out cout
#endif

int main() {
	int q;
	In >> q;
	while (q--) {
		int n;
		In >> n;
		vi v;
		for (int i = 0; i < n; i++) {
			int t;
			In >> t;
			v.push_back(t);
		}

		sort(v.begin(), v.end());

		int mind = 100000;
		for (int i = 1; i < n; i++) {
			mind = min(mind, v[i] - v[i - 1])
		}

		Out << mind << endl;

	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

const int N = 55;
int a[N];
int main()
{
    int t;cin>>t;
    while (t--)
    {
        int n; cin >>n;
        for (int i = 0; i <n; i++) cin>>a[i];
        sort(a, a +n);
        int ans = 11111111;
        for(int i = 1; i < n; i++)
        {
            ans = min(a[i] - a[i-1], ans);
        }
        cout <<ans <<endl;
    }
}


#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <assert.h>
#include <map>
#include <set>
#include <bitset>
#include <iomanip>
#include <stack>
// #include <unordered_map>
#include <cmath>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define INF 0x7f7f7f7f  //2139062143
#define INF1 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.14159265358979323846264338327950254
#define pb push_back
#define ll long long
#define debug cout << "debug\n";
#define STDIN                      \
    freopen("in.txt", "r", stdin); \
    freopen("out.txt", "w", stdout);
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);
#define scai(x) scanf("%d", &x)
#define sca2i(x, y) scanf("%d %d", &x, &y)
#define scaf(x) scanf("%lf", &x)
#define sca2f(x, y) scanf("%lf %lf", &x, &y)
#define For(m, n) for (int i = m; i < n; i++)
#define PII pair<int, int>
#define PLL pair<long, long>
#define ft first
#define sd second
#define pb push_back
#define ST(x,y,z) sort(x + y, x + z);
#define lson o << 1, l, mid
#define rson o << 1 | 1, mid + 1, r
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define ROF(i, a, b) for (int i = (a); i >= (b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define rrep(i, a, b) for (register int i = a; i >= b; i--)
#define PIII pair<int, PII>
// #define int ll
inline int read()
{
    char ch = getchar();
    int x = 0, f = 0;
    while (ch < '0' || ch > '9')
        f |= ch == '-', ch = getchar();
    while (ch >= '0' && ch <= '9')
        x = x * 10 + ch - '0', ch = getchar();
    return f ? -x : x;
}

#define int ll

const int N = 50;
int a[N];
int b[N];
signed main()
{
    // STDIN
    int t; cin >> t;
    while (t--)
    {
        int n; cin >> n;
        rep(i, 1, n)
        {
            cin >> a[i];
            b[i] = a[i];
        }
        sort(b + 1, b + 1 + n);
        int ans = 0x3f3f3f3f;
        rep(i, 2, n)
        {
            ans = min(b[i] - b[i - 1], ans);
        }
        cout << ans << endl;
    }
}


#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <string>
#include <math.h>
#include <cstdio>
#include <algorithm>
#include <time.h>
using namespace std;

int main()
{
    int z = 0;
    cin>>z;
    for(int m = 0; m<z; m++)
    {
        int n = 0;
        cin>>n;
        int arr[n] = {0};
        for(int i = 0; i<n; i++)
        {
            cin>>arr[i];
        }
        int temp = 0;
        int minn = 10000;
        for(int i = 0; i<n-1; i++)
        {
            for(int a= i; a<n-1; a++)
            {
                if(abs(arr[a+1]-arr[i])<minn)
                {

                    minn = abs(arr[a+1]-arr[i]);
                }
            }
        }
        cout<<minn;
    }

}


#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <string>
#include <math.h>
#include <cstdio>
#include <algorithm>
#include <time.h>
#include "conio.h"
using namespace std;

int main()
{
    int z = 0;
    cin>>z;
    for(int m = 0; m<z; m++)
    {
        int n = 0;
        cin>>n;
        int arr[n] = {0};
        for(int i = 0; i<n; i++)
        {
            cin>>arr[i];
        }
        int temp = 0;
        int minn = 10000;
        for(int i = 0; i<n-1; i++)
        {
            for(int a= i; a<n-1; a++)
            {
                if(abs(arr[a+1]-arr[i])<minn)
                {

                    minn = abs(arr[a+1]-arr[i]);
                }
            }
        }
        cout<<minn;
    }

}


#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <string>
#include <math.h>
#include <cstdio>
#include <algorithm>
#include <time.h>
using namespace std;

int main()
{
    int z = 0;
    cin>>z;
    for(int m = 0; m<z; m++)
    {
        int n = 0;
        cin>>n;
        int arr[10000] = {0};
        for(int i = 0; i<n; i++)
        {
            cin>>arr[i];
        }
        int temp = 0;
        int minn = 10000;
        for(int i = 0; i<n-1; i++)
        {
            for(int a= i; a<n-1; a++)
            {
                if(abs(arr[a+1]-arr[i])<minn)
                {

                    minn = abs(arr[a+1]-arr[i]);
                }
            }
        }
        cout<<minn;
    }

}


#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <string>
#include <math.h>
#include <cstdio>
#include <algorithm>
#include <time.h>
using namespace std;

int main()
{
    int z = 0;
    cin>>z;
    for(int m = 0; m<z; m++)
    {
        int n = 0;
        cin>>n;
        int arr[10000] = {0};
        for(int i = 0; i<n; i++)
        {
            cin>>arr[i];
        }
        int temp = 0;
        int minn = 10000;
        for(int i = 0; i<n-1; i++)
        {
            for(int a= i; a<n-1; a++)
            {
                if(abs(arr[a+1]-arr[i])<minn)
                {

                    minn = abs(arr[a+1]-arr[i]);
                }
            }
        }
        cout<<minn<<endl;
    }

}


#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int t,a[10000];
    cin>>t;
    for (int z=0;z<t;z++){
        int n;
        cin>>n;
        for (int i=0;i<n;i++) cin>>a[i];
        sort(a,a+n);
        if (n==2) cout<<a[1]-a[0]<<endl;
        else {
            int min=a[2]-a[1];
            for (int i=2;i<n;i++) {
               int kc=a[i]-a[i-1];
               if(min>kc) min=kc;
            }
            cout<<min<<endl;
        }
        for (int i=0;i<n;i++) a[i]=0;
    }
}


#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int t,a[10000];
    cin>>t;
    for (int z=0;z<t;z++){
        int n;
        cin>>n;
        for (int i=0;i<n;i++) cin>>a[i];
        sort(a,a+n);
        if (n==2) cout<<a[1]-a[0]<<endl;
        else {
            int min=a[1]-a[0];
            for (int i=1;i<n;i++) {
               int kc=a[i]-a[i-1];
               if(min>kc) min=kc;
            }
            cout<<min<<endl;
        }
        for (int i=0;i<n;i++) a[i]=0;
    }
}


#include <iostream>
#include <string>
#include<deque>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<tuple>

#define maxn 200001
#define LL long long
#define inf 1000000000

using namespace std;

struct edge {
	int dis;
	int st;
	int ed;

	edge(int dis, int st, int ed) {
		this->dis = dis;
		this->st = st;
		this->ed = ed;
	}
	bool operator < (const edge& rhs)const {
		if (dis == rhs.dis) {
			if (st == rhs.st)
				return ed < rhs.ed;
			return st < rhs.st;
		}
		return dis < rhs.dis;

	}
};
bool desc(int a, int b) { return a > b; }
int gcd(int a, int b) {
	if (a < b) swap(a, b);
	while (!b == 0) {
		int r = a % b;
		a = b;
		b = r;
	}
	return a;
}
//int getParent(int set[], int x) {
//	if (set[x] == x)return x;
//	return set[x] = getParent(set, set[x]);
//}
//void unionParent(int set[], int a, int b) {
//	a = getParent(set, a);
//	b = getParent(set, b);
//
//	if (a < b)set[b] = a;
//	else set[a] = b;
//
//}
//
//int find(int set[], int a, int b) {
//	a = getParent(set, a);
//	b = getParent(set, b);
//	if (a == b)return 1;
//	else return 0;
//}
//int krusckal(int num) {
//	int sum = 0;
//	int set[maxn];
//	for (int i = 1; i <= num; ++i) {
//		set[i] = i;
//	}
//	for (auto it = S.begin(); it !=S.end(); ++it) {
//		if (!find(set,(*it).st, (*it).ed)) {
//			sum += (*it).dis;
//			unionParent(set, (*it).st, (*it).ed);
//		}
//	}
//
//	for (int i = 1; i <= num; ++i) {
//		getParent(set, i);
//	}
//	bool flg = true;
//	int parent = set[1];
//	for (int i = 2; i <= num; ++i) {
//		if (parent != set[i])
//			return -1;
//	}
//	return sum;
//}

int n, m;
int ans;
int dx[9] = { -1,0,1,0,0,1,1,-1,-1 };
int dy[9] = { 0,1,0,-1,0,1,-1,1,-1 };
int arr[maxn];

int main() {

	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t;
	cin >> t;
	for (int test_case = 0; test_case < t; ++test_case) {
		LL n, k;
		cin >> n;
		for (int i = 0; i < n; ++i) {
			cin >> arr[i];
		}
		sort(arr, arr + n);
		int tmp = arr[0];
		int dif = inf;
		for (int i = 1; i < n; ++i) {
			if (arr[i] == tmp) {
				dif = 0;
				break;
			}
			if (abs(arr[i] - tmp) < dif) {
				dif = abs(arr[i] - tmp);
				tmp = arr[i];

			}
		}

		cout << dif << '\n';
		//cout << '#' << test_case+1 << ' ' << ans << '\n';
	}
	return 0;
}


#include <iostream>
#include <string>
#include<deque>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<tuple>

#define maxn 200001
#define LL long long
#define inf 1000000000

using namespace std;

struct edge {
	int dis;
	int st;
	int ed;

	edge(int dis, int st, int ed) {
		this->dis = dis;
		this->st = st;
		this->ed = ed;
	}
	bool operator < (const edge& rhs)const {
		if (dis == rhs.dis) {
			if (st == rhs.st)
				return ed < rhs.ed;
			return st < rhs.st;
		}
		return dis < rhs.dis;

	}
};
bool desc(int a, int b) { return a > b; }
int gcd(int a, int b) {
	if (a < b) swap(a, b);
	while (!b == 0) {
		int r = a % b;
		a = b;
		b = r;
	}
	return a;
}
//int getParent(int set[], int x) {
//	if (set[x] == x)return x;
//	return set[x] = getParent(set, set[x]);
//}
//void unionParent(int set[], int a, int b) {
//	a = getParent(set, a);
//	b = getParent(set, b);
//
//	if (a < b)set[b] = a;
//	else set[a] = b;
//
//}
//
//int find(int set[], int a, int b) {
//	a = getParent(set, a);
//	b = getParent(set, b);
//	if (a == b)return 1;
//	else return 0;
//}
//int krusckal(int num) {
//	int sum = 0;
//	int set[maxn];
//	for (int i = 1; i <= num; ++i) {
//		set[i] = i;
//	}
//	for (auto it = S.begin(); it !=S.end(); ++it) {
//		if (!find(set,(*it).st, (*it).ed)) {
//			sum += (*it).dis;
//			unionParent(set, (*it).st, (*it).ed);
//		}
//	}
//
//	for (int i = 1; i <= num; ++i) {
//		getParent(set, i);
//	}
//	bool flg = true;
//	int parent = set[1];
//	for (int i = 2; i <= num; ++i) {
//		if (parent != set[i])
//			return -1;
//	}
//	return sum;
//}

int n, m;
int ans;
int dx[9] = { -1,0,1,0,0,1,1,-1,-1 };
int dy[9] = { 0,1,0,-1,0,1,-1,1,-1 };
int arr[maxn];

int main() {

	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t;
	cin >> t;
	for (int test_case = 0; test_case < t; ++test_case) {
		LL n, k;
		cin >> n;
		for (int i = 0; i < n; ++i) {
			cin >> arr[i];
		}
		sort(arr, arr + n);
		int dif = inf;
		for (int i = 1; i < n; ++i) {
			if (arr[i-1] == arr[i]) {
				dif = 0;
				break;
			}
			if (abs(arr[i] - arr[i-1]) < dif) {
				dif = abs(arr[i] - arr[i-1]);
			}
		}

		cout << dif << '\n';
		//cout << '#' << test_case+1 << ' ' << ans << '\n';
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>

using namespace std;

int a[55];

int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n;
		cin >> n;
		for (int i = 1; i <= n; i++)
		{
			cin >> a[i];
		}
		sort(a + 1, a + 1 + n);
		int ans = 1e9 + 7;
		for (int i = 2; i <= n; i++)
		{
			ans = min(ans, a[i] - a[i - 1]);
		}
		cout << ans << endl;
	}
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int t=0;
    cin>>t;
    while(t--)
    {
        int n=0,min=100000;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a,a+n);
        for(int i=0;i<(n-1);i++)
        {
            if((a[i+1]-a[i])<=min)
                min=(a[i+1]-a[i]);
        }
        cout<<min<<"\n";
    }
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int t=0;
    cin>>t;
    while(t--)
    {
        int n=0,min=100000;
        cin>>n;
        int *a=new int[n];
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a,a+n);
        for(int i=0;i<(n-1);i++)
        {
            if((a[i+1]-a[i])<=min)
                min=(a[i+1]-a[i]);
        }
        cout<<min<<"\n";
    }
    return 0;
}


import java.util.Scanner;
public class Train9 {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        String s=Integer.toString(n);
        if(s.length()==1)
            System.out.println(0);
        else
        {
            if(s.charAt(s.length()-1)=='0')
            {
                int i;
                for(i=1;i<s.length()-1;i++)
                {
                    if(s.charAt(s.length()-i)!='0')
                       break;
                }
                System.out.println(s.length()-i);
            }
            else
            {
                System.out.println(s.length());
            }

        }

    }}


import java.util.Scanner;
public class Train9 {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        int total;
        int z;
        if(n<10)
            System.out.println(0);
        else
        {
            int i=0;
            do
            {
                total=0;
                while(n>0)
                {
                z=n%10;
                n=n/10;
                total+=z;
                }
                n=total;
                i++;
            }while(total>9);
            System.out.println(i);
        }

    }}


import java.util.Scanner;
public class Train9 {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        String n=scan.nextLine();
        long sum;
        long j;
        if(n.length()==1)
            System.out.println(0);
        else
        {
            for(j=0;n.length()>1;j++){
            sum=0;
            for (int i=0;i<n.length();i++)
            {
                sum+=(int)(n.charAt(i)-'0');
            }
            n=String.valueOf(sum);
            }
            System.out.println(j);
        }

    }}


import java.util.Scanner;
public class Train9 {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        long n=scan.nextInt();
        int total;
        long z;
        if(n<10)
            System.out.println(0);
        else
        {
            int i=0;
            do
            {
                total=0;
                while(n>0)
                {
                z=n%10;
                n=n/10;
                total+=z;
                }
                n=total;
                i++;
            }while(total>9);
            System.out.println(i);
        }

    }}


import java.util.Scanner;
public class Train9 {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        String s=Integer.toString(n);
        if(s.length()==1)
            System.out.println(0);
        else
        {
            if(s.charAt(s.length()-1)=='0')
            {
                System.out.println(s.length()-1);
            }
            else
            {
                System.out.println(s.length());
            }

        }

    }}


import java.util.Scanner;
public class Train9 {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        String s=Integer.toString(n);
        if(n<10)
            System.out.println(0);
        else
        {
            if(n>=10&&n<100)
                System.out.println(1);
            else
            {
                System.out.println(s.length());
            }

        }

    }}


import java.util.*;
import java.io.*;
import java.math.*;

public class JavaSolver
{

    public static void main(String[] args) throws IOException
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task(in, out);
        solver.solve();
        out.close();
    }
}

class Task
{
    private final InputReader in;
    private final PrintWriter out;

    public Task(InputReader in, PrintWriter out)
    {
        this.in = in;
        this.out = out;
    }

    public void solve() throws IOException
    {///////////////////////////////////////////////////////////////////////////
        int res = 1, num = 0;
        int n = 0;

        //BufferedInputStream bis = new BufferedInputStream(new FileInputStream("in.txt"));
        BufferedInputStream bis = new BufferedInputStream(System.in);

        int readBuf = bis.read();

        while(readBuf != -1)
        {
            n++;
            num += readBuf - 48;
            readBuf = bis.read();
        }

        if(num < 1)
        {
            out.println(0);
            return;
        }

        String str = String.valueOf(num);

        while(str.length() > 1)
        {
            num = 0;
            for(int i = 0; i < str.length(); i++)
            {
                num += str.charAt(i) - 48;
            }
            str = String.valueOf(num);
            res++;
        }

        out.println(res);
    }///////////////////////////////////////////////////////////////////////////
}

class InputReader
{

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream)
    {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine()
    {
        try
        {
            return reader.readLine();
        } catch (IOException e)
        {
            throw new RuntimeException(e);
        }
    }

    public String next()
    {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
        {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt()
    {
        return Integer.parseInt(next());
    }

    public long nextLong()
    {
        return Long.parseLong(next());
    }

    public double nextDouble()
    {
        return Double.parseDouble(next());
    }

    public float nextFloat()
    {
        return Float.parseFloat(next());
    }
}


import java.util.*;
import java.io.*;
import java.math.*;

public class JavaSolver
{

    public static void main(String[] args) throws IOException
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task(in, out);
        solver.solve();
        out.close();
    }
}

class Task
{
    private final InputReader in;
    private final PrintWriter out;

    public Task(InputReader in, PrintWriter out)
    {
        this.in = in;
        this.out = out;
    }

    public void solve() throws IOException
    {///////////////////////////////////////////////////////////////////////////
        int res = 1, num = 0;
        int n = 0;

        //BufferedInputStream bis = new BufferedInputStream(new FileInputStream("in.txt"));
        BufferedInputStream bis = new BufferedInputStream(System.in);

        int readBuf = bis.read();

        while(readBuf >= '0' && readBuf <= '9')
        {
            n++;
            num += readBuf - 48;
            readBuf = bis.read();
        }

        if(num < 1)
        {
            out.println(0);
            return;
        }

        String str = String.valueOf(num);

        while(str.length() > 1)
        {
            num = 0;
            for(int i = 0; i < str.length(); i++)
            {
                num += str.charAt(i) - 48;
            }
            str = String.valueOf(num);
            res++;
        }

        out.println(res);
    }///////////////////////////////////////////////////////////////////////////
}

class InputReader
{

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream)
    {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine()
    {
        try
        {
            return reader.readLine();
        } catch (IOException e)
        {
            throw new RuntimeException(e);
        }
    }

    public String next()
    {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
        {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt()
    {
        return Integer.parseInt(next());
    }

    public long nextLong()
    {
        return Long.parseLong(next());
    }

    public double nextDouble()
    {
        return Double.parseDouble(next());
    }

    public float nextFloat()
    {
        return Float.parseFloat(next());
    }
}


import java.util.*;
import java.io.*;
import java.math.*;

public class JavaSolver
{

    public static void main(String[] args) throws IOException
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task(in, out);
        solver.solve();
        out.close();
    }
}

class Task
{
    private final InputReader in;
    private final PrintWriter out;

    public Task(InputReader in, PrintWriter out)
    {
        this.in = in;
        this.out = out;
    }

    public void solve() throws IOException
    {///////////////////////////////////////////////////////////////////////////
        int res = 1, num = 0;
        int n = 0;

       //BufferedInputStream bis = new BufferedInputStream(new FileInputStream("in.txt"));
        BufferedInputStream bis = new BufferedInputStream(System.in);

        int readBuf = bis.read();

        while(readBuf != -1)
        {
            n++;
            num += readBuf - 48;
            readBuf = bis.read();
        }

        if(num < 1)
        {
            out.println(0);
            return;
        }

        String str = String.valueOf(num);

        while(str.length() > 1)
        {
            num = 0;
            for(int i = 0; i < str.length(); i++)
            {
                num += str.charAt(i) - 48;
            }
            str = String.valueOf(num);
            res++;
        }

        out.println(res);
    }///////////////////////////////////////////////////////////////////////////
}

class InputReader
{

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream)
    {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine()
    {
        try
        {
            return reader.readLine();
        } catch (IOException e)
        {
            throw new RuntimeException(e);
        }
    }

    public String next()
    {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
        {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt()
    {
        return Integer.parseInt(next());
    }

    public long nextLong()
    {
        return Long.parseLong(next());
    }

    public double nextDouble()
    {
        return Double.parseDouble(next());
    }

    public float nextFloat()
    {
        return Float.parseFloat(next());
    }
}


import java.util.*;
import java.io.*;
import java.math.*;

public class JavaSolver
{

    public static void main(String[] args) throws IOException
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task(in, out);
        solver.solve();
        out.close();
    }
}

class Task
{
    private final InputReader in;
    private final PrintWriter out;

    public Task(InputReader in, PrintWriter out)
    {
        this.in = in;
        this.out = out;
    }

    public void solve() throws IOException
    {///////////////////////////////////////////////////////////////////////////
        int res = 1, num = 0;
        int n = 0;

        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("in.txt"));
        //BufferedInputStream bis = new BufferedInputStream(System.in);

        int readBuf = bis.read();

        while(readBuf >= '0' && readBuf <= '9')
        {
            n++;
            num += readBuf - 48;
            readBuf = bis.read();
        }

        if(num < 1)
        {
            out.println(0);
            return;
        }

        String str = String.valueOf(num);

        while(str.length() > 1)
        {
            num = 0;
            for(int i = 0; i < str.length(); i++)
            {
                num += str.charAt(i) - 48;
            }
            str = String.valueOf(num);
            res++;
        }

        out.println(res);
    }///////////////////////////////////////////////////////////////////////////
}

class InputReader
{

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream)
    {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine()
    {
        try
        {
            return reader.readLine();
        } catch (IOException e)
        {
            throw new RuntimeException(e);
        }
    }

    public String next()
    {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
        {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt()
    {
        return Integer.parseInt(next());
    }

    public long nextLong()
    {
        return Long.parseLong(next());
    }

    public double nextDouble()
    {
        return Double.parseDouble(next());
    }

    public float nextFloat()
    {
        return Float.parseFloat(next());
    }
}


import java.util.*;
import java.io.*;
import java.math.*;

public class JavaSolver
{

    public static void main(String[] args) throws IOException
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task(in, out);
        solver.solve();
        out.close();
    }
}

class Task
{
    private final InputReader in;
    private final PrintWriter out;

    public Task(InputReader in, PrintWriter out)
    {
        this.in = in;
        this.out = out;
    }

    public void solve() throws IOException
    {///////////////////////////////////////////////////////////////////////////
        int res = 1, num = 0;
        int n = 0;

        //BufferedInputStream bis = new BufferedInputStream(new FileInputStream("in.txt"));
        BufferedInputStream bis = new BufferedInputStream(System.in);

        int readBuf = bis.read();

        while(readBuf >= '0' && readBuf <= '9')
        {
            n++;
            num += readBuf - 48;
            readBuf = bis.read();
        }

        if(n < 2)
        {
            out.println(0);
            return;
        }

        String str = String.valueOf(num);

        while(str.length() > 1)
        {
            num = 0;
            for(int i = 0; i < str.length(); i++)
            {
                num += str.charAt(i) - 48;
            }
            str = String.valueOf(num);
            res++;
        }

        out.println(res);
    }///////////////////////////////////////////////////////////////////////////
}

class InputReader
{

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream)
    {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine()
    {
        try
        {
            return reader.readLine();
        } catch (IOException e)
        {
            throw new RuntimeException(e);
        }
    }

    public String next()
    {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
        {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt()
    {
        return Integer.parseInt(next());
    }

    public long nextLong()
    {
        return Long.parseLong(next());
    }

    public double nextDouble()
    {
        return Double.parseDouble(next());
    }

    public float nextFloat()
    {
        return Float.parseFloat(next());
    }
}


import java.util.*;
import java.io.*;
import java.math.*;

public class JavaSolver
{

    public static void main(String[] args) throws IOException
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task(in, out);
        solver.solve();
        out.close();
    }
}

class Task
{
    private final InputReader in;
    private final PrintWriter out;

    public Task(InputReader in, PrintWriter out)
    {
        this.in = in;
        this.out = out;
    }

    public void solve() throws IOException
    {///////////////////////////////////////////////////////////////////////////
        int res = 1, num = 0;
        int n = 0;

        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("in.txt"));

        int readBuf = bis.read();

        while(readBuf != -1)
        {
            n++;
            num += readBuf - 48;
            readBuf = bis.read();
        }

        if(num < 1)
        {
            out.println(0);
            return;
        }

        String str = String.valueOf(num);

        while(str.length() > 1)
        {
            num = 0;
            for(int i = 0; i < str.length(); i++)
            {
                num += str.charAt(i) - 48;
            }
            str = String.valueOf(num);
            res++;
        }

        out.println(res);
    }///////////////////////////////////////////////////////////////////////////
}

class InputReader
{

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream)
    {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine()
    {
        try
        {
            return reader.readLine();
        } catch (IOException e)
        {
            throw new RuntimeException(e);
        }
    }

    public String next()
    {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
        {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt()
    {
        return Integer.parseInt(next());
    }

    public long nextLong()
    {
        return Long.parseLong(next());
    }

    public double nextDouble()
    {
        return Double.parseDouble(next());
    }

    public float nextFloat()
    {
        return Float.parseFloat(next());
    }
}


import java.io.*;
import java.util.*;
public class Main{
  public static void main(String[] args){
      Scanner in = new Scanner(System.in);
      String n = in.next();
      int count = 0;long sum = 0;
      if(sum <= 2){
          System.out.println(count++);
      }
      else{
          count++;
      for(int i =0;i<n.length();i++){
          sum+=n.charAt(i);
      }
      n = String.valueOf(sum);
      }

  }
}


package m2511;

import java.io.*;
import java.util.*;
public class jojo{
  public static void main(String[] args){
      Scanner in = new Scanner(System.in);
      String n = in.next();
      int count = 0,sum = 11;
      if(n.length() < 2){
          System.out.println("0");return;
      }
      while (sum >= 10){
  		sum = 0;
  		for (int i = 0;i < n.length();i++)
  		{
  			sum += Integer.valueOf(n.charAt(i)+"");                 // 991    x=0+1+0=1
  		}

  		n =String.valueOf(sum);                       // s1=1

  		count++;                                //count=1+1 +1 =3
  	}
  	System.out.println(sum);
  }
}


import java.io.*;
import java.util.*;
public class jojo{
  public static void main(String[] args){
      Scanner in = new Scanner(System.in);
      String n = in.next();
      int count = 0,sum = 11;
      if(n.length() < 2){
          System.out.println("0");return;
      }
      while (sum >= 10){
  		sum = 0;
  		for (int i = 0;i < n.length();i++)
  		{
  			sum += Integer.valueOf(n.charAt(i)+"");                 // 991    x=0+1+0=1
  		}

  		n =String.valueOf(sum);                       // s1=1

  		count++;                                //count=1+1 +1 =3
  	}
  	System.out.println(count);
  }
}


import java.io.*;
import java.util.*;
public class jojo{
  public static void main(String[] args){
      Scanner in = new Scanner(System.in);
      String n = in.next();
      int count = 0,sum = 11;
      if(n.length() < 2){
          System.out.println("0");return;
      }
      while (sum >= 10){
  		sum = 0;
  		for (int i = 0;i < n.length();i++)
  		{
  			sum += Integer.valueOf(n.charAt(i)+"");                 // 991    x=0+1+0=1
  		}

  		n =String.valueOf(sum);                       // s1=1

  		count++;                                //count=1+1 +1 =3
  	}
  	System.out.println(sum);
  }
}


import java.util.Scanner;

public class SumDigit {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        int count = 0;

        while (n > 9) {
           n= sumDigit(n);
            count++;

        }
            System.out.println(count);

    }

    public static long sumDigit(long n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n = n / 10;
        }
        return sum;
    }
}


import java.math.BigInteger;
import java.util.Scanner;
import static sun.security.krb5.Confounder.intValue;

public class SumDigit {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        BigInteger n = in.nextBigInteger();
        //long n = in.nextLong();
        int count = 0;
        //  n = Math.();
        String s = sumDigit(n) + "";
        while (true) {
            count++;
            if (s.length() == 1) {

                System.out.println(count);
                System.exit(0);
            }
            s = sumDigit(BigInteger.valueOf(Integer.parseInt(s))) + "";
        }
    }

    public static long sumDigit(BigInteger n) {

        String digits = n.toString();
        int sum = 0;

        for (int i = 0; i < digits.length(); i++) {
            int digit = (int) (digits.charAt(i) - '0');
            sum = sum + digit;
        }

        return sum;
    }
}


import java.math.BigInteger;
import java.util.Scanner;
import static sun.security.krb5.Confounder.intValue;

public class SumDigit {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
//
        BigInteger n = in.nextBigInteger();
        //long n = in.nextLong();
        int count = 0;
        //  n = Math.();
//        if (n.intValue() <= 9) {
//            System.out.println(0);
//            System.exit(0);
//        }
        long num = n.intValue();
//        while (s >= 9) {
//            count++;
////            s = sumDigit(BigInteger.valueOf(Integer.parseInt(s))) + "";
//            s = sumDigit(BigInteger.valueOf(s));
//        }
//        System.out.println(count);
        while (num > 9) {
            num = sumDigit(num);
            count++;

        }
        System.out.println(count);

    }

    public static int sumDigit(Long n) {

        String digits = n.toString();
        int sum = 0;

        for (int i = 0; i < digits.length(); i++) {
            int digit = (int) (digits.charAt(i) - '0');
            sum = sum + digit;
        }

        return sum;
    }
}


import java.math.BigInteger;
import java.util.Scanner;
import static sun.security.krb5.Confounder.intValue;

public class SumDigit {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
//
        String n = in.next();
        //long n = in.nextLong();
        int count = 0;

        while (n.length() > 1) {
            n = sumDigit(n);
            count++;

        }
        System.out.println(count);

    }

    public static String sumDigit(String n) {

        //String digits = n.toString();
        int sum = 0;

        for (int i = 0; i < n.length(); i++) {
             sum += (int) (n.charAt(i) - '0');

        }

        return sum+"";
    }
}


import java.util.Scanner;

public class CF102_D2_B {
    public static String permit(String a){
        long k=0;
        for (int i=0;i<a.length();i++){
            k+= new Long(a.charAt(i));
        }

        return String.valueOf(k);
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String n;
        int out=0;
        n=sc.next();
        while (true){
            if (n.length()<=1)
                break;
            out++;
            n=permit(n);
        }
        System.out.println(out);
    }
}


import java.util.Scanner;

public class CF102_D2_B {
    public static String permit(String a){
        long k=0;
        for (int i=0;i<a.length();i++){
            k+= a.charAt(i)-48;
        }

        return String.valueOf(k);
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String n;
        int out=0;
        n=sc.next();
        while (true){
            if (n.length()<=1)
                break;
            out++;
            n=permit(n);
        }
        System.out.println(out);
    }
}


import java.util.Scanner;

public class CF102_D2_B {
    public static int permit(int a){
        int k=0;
        while (true){
            if (a<=0)
                break;
            k+=a%10;
            a=a/10;

        }

        return k;
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n,out=0;
        n=sc.nextInt();
        while (true){
            if (n<10)
                break;
            out++;
            n=permit(n);
        }
        System.out.println(out);
    }
}


import java.util.Scanner;

public class CF102_D2_B {
    public static String permit(String a){
        long k=0;
        for (int i=0;i<a.length();i++){
            k+= a.charAt(i)-48;
            System.out.println(a.charAt(i)+"==>"+k);
        }

        return String.valueOf(k);
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String n;
        int out=0;
        n=sc.next();
        while (true){
            if (n.length()<=1)
                break;
            out++;
            n=permit(n);
        }
        System.out.println(out);
    }
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int counter = 0;
        int current = sc.nextInt();
        int numberOfDigits = (int) Math.log10(current);
        //System.out.println(numberOfDigits);

        int currentTray=0;

        while(Math.log10(current)>=1) {
            currentTray=0;
             numberOfDigits = (int) Math.log10(current);
            int temp = current;
            for (int i = numberOfDigits; i >= 0; i--) {
                int constant = (int) Math.pow(10, i);
                //System.out.println(constant);
               //System.out.println(temp / constant);
                currentTray = currentTray + (temp / constant);
                temp = temp - (constant * (int) (temp / constant));
            }
            current = currentTray;
           //System.out.println(current);
            counter++;
        }
        System.out.println(counter);
    }

    static long fibDp(long[] memo, int n) {
        if (n <= 1)
            return n;
        if (memo[n] > 0) return memo[n];
        long result = fibDp(memo, n - 1) + fibDp(memo, n - 2);
        memo[n] = result;
        return result;
    }

    static int fib(int n) {
        if (n <= 1)
            return n;
        return fib(n - 1) + fib(n - 2);
    }

}


import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int counter = 0;
        String str = sc.next();
        int current = 0;

        if(str.length()<=1){
            System.out.println(0);
            return;
        }
        else {
        for (int i = 0; i < str.length() ; i++) {
            current = current+str.charAt(i);
        }
        counter++;
        }

        int numberOfDigits;
        //System.out.println(numberOfDigits);

        int currentTray=0;

        while(Math.log10(current)>=1) {
            currentTray=0;
            numberOfDigits = (int) Math.log10(current);
            int temp = current;
            for (int i = numberOfDigits; i >= 0; i--) {
                int constant = (int) Math.pow(10, i);
                //System.out.println(constant);
                //System.out.println(temp / constant);
                currentTray = currentTray + (temp / constant);
                temp = temp - (constant * (int) (temp / constant));
            }
            current = currentTray;
            //System.out.println(current);
            counter++;
        }
        System.out.println(counter);
    }

    static long fibDp(long[] memo, int n) {
        if (n <= 1)
            return n;
        if (memo[n] > 0) return memo[n];
        long result = fibDp(memo, n - 1) + fibDp(memo, n - 2);
        memo[n] = result;
        return result;
    }

    static int fib(int n) {
        if (n <= 1)
            return n;
        return fib(n - 1) + fib(n - 2);
    }

}


package com.company;

import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int counter = 0;
        String str = sc.next();
        int current = 0;

        if(str.length()<=1){
            System.out.println(0);
            return;
        }
        else {
        for (int i = 0; i < str.length() ; i++) {
            current = current+str.charAt(i);
        }
        counter++;
        }

        int numberOfDigits;
        //System.out.println(numberOfDigits);

        int currentTray=0;

        while(Math.log10(current)>=1) {
            currentTray=0;
            numberOfDigits = (int) Math.log10(current);
            int temp = current;
            for (int i = numberOfDigits; i >= 0; i--) {
                int constant = (int) Math.pow(10, i);
                //System.out.println(constant);
                //System.out.println(temp / constant);
                currentTray = currentTray + (temp / constant);
                temp = temp - (constant * (int) (temp / constant));
            }
            current = currentTray;
            //System.out.println(current);
            counter++;
        }
        System.out.println(counter);
    }

    static long fibDp(long[] memo, int n) {
        if (n <= 1)
            return n;
        if (memo[n] > 0) return memo[n];
        long result = fibDp(memo, n - 1) + fibDp(memo, n - 2);
        memo[n] = result;
        return result;
    }

    static int fib(int n) {
        if (n <= 1)
            return n;
        return fib(n - 1) + fib(n - 2);
    }

}


import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int counter = 0;
        String str = sc.next();
        int current = 0;

        if(str.length()<=1){
            System.out.println(0);
            return;
        }
        else {
        for (int i = 0; i < str.length() ; i++) {
            current = current+(str.charAt(i)-'0');
        }
        counter++;
        }

        int numberOfDigits;
        //System.out.println(numberOfDigits);

        int currentTray=0;

        while(Math.log10(current)>=1) {
            currentTray=0;
            numberOfDigits = (int) Math.log10(current);
            int temp = current;
            for (int i = numberOfDigits; i >= 0; i--) {
                int constant = (int) Math.pow(10, i);
                //System.out.println(constant);
                //System.out.println(temp / constant);
                currentTray = currentTray + (temp / constant);
                temp = temp - (constant * (int) (temp / constant));
            }
            current = currentTray;
            //System.out.println(current);
            counter++;
        }
        System.out.println(counter);
    }

    static long fibDp(long[] memo, int n) {
        if (n <= 1)
            return n;
        if (memo[n] > 0) return memo[n];
        long result = fibDp(memo, n - 1) + fibDp(memo, n - 2);
        memo[n] = result;
        return result;
    }

    static int fib(int n) {
        if (n <= 1)
            return n;
        return fib(n - 1) + fib(n - 2);
    }

}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long digit = in.nextInt();
        int counter = 0;
        long sum = digit;
        while (sum>9){
            long sumLoc = 0;
            counter++;
            while (digit != 0)
            {
                sumLoc += (digit % 10);
                digit /= 10;
            }
            digit = sumLoc;
            sum = digit;
        }

        System.out.print(counter);
    }

}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int digit = in.nextInt();
        int counter = 0;
        int sum = digit;
        while (sum>9){
            int sumLoc = 0;
            counter++;
            while (digit != 0)
            {
                sumLoc += (digit % 10);
                digit /= 10;
            }
            digit = sumLoc;
            sum = digit;
        }

        System.out.print(counter);
    }

}


package com.company;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long digit = in.nextInt();
        int counter = 0;
        long sum = digit;
        while (sum>9){
            long sumLoc = 0;
            counter++;
            while (digit != 0)
            {
                sumLoc += (digit % 10);
                digit /= 10;
            }
            digit = sumLoc;
            sum = digit;
        }

        System.out.print(counter);
    }

}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long digit = in.nextLong();
        int counter = 0;
        long sum = digit;
        while (sum>9){
            long sumLoc = 0;
            counter++;
            while (digit != 0)
            {
                sumLoc += (digit % 10);
                digit /= 10;
            }
            digit = sumLoc;
            sum = digit;
        }

        System.out.print(counter);
    }

}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double digit = in.nextDouble();
        double counter = 0;
        double sum = digit;
        while (sum>9){
            double sumLoc = 0;
            counter++;
            while (digit != 0)
            {
                sumLoc += (digit % 10);
                digit /= 10;
            }
            digit = sumLoc;
            sum = digit;
        }

        System.out.print(counter);
    }

}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long digit = in.nextLong();
        if ((digit>=0)&&(digit<=Math.pow(10,100000))) {
            int counter = 0;
            long sum = digit;
            while (sum > 9) {
                long sumLoc = 0;
                counter++;
                while (digit != 0) {
                    sumLoc += (digit % 10);
                    digit /= 10;
                }
                digit = sumLoc;
                sum = digit;
            }

            System.out.print(counter);
        }
    }
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int digit = in.nextInt();
        if ((digit>=0)&&(digit<=Math.pow(10,100000))) {
            int counter = 0;
            int sum = digit;
            while (sum > 9) {
                int sumLoc = 0;
                counter++;
                while (digit != 0) {
                    sumLoc += (digit % 10);
                    digit /= 10;
                }
                digit = sumLoc;
                sum = digit;
            }

            System.out.print(counter);
        }
    }
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long digit = in.nextInt();
        long counter = 0;
        long sum = digit;
        while (sum>9){
            long sumLoc = 0;
            counter++;
            while (digit != 0)
            {
                sumLoc += (digit % 10);
                digit /= 10;
            }
            digit = sumLoc;
            sum = digit;
        }

        System.out.print(counter);
    }

}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long digit = in.nextLong();
        if ((digit>0)&&(digit<Math.pow(10,100000))) {
            int counter = 0;
            long sum = digit;
            while (sum > 9) {
                long sumLoc = 0;
                counter++;
                while (digit != 0) {
                    sumLoc += (digit % 10);
                    digit /= 10;
                }
                digit = sumLoc;
                sum = digit;
            }

            System.out.print(counter);
        }
    }
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long digit = in.nextLong();
        int counter = 0;
        long sum = digit;
        while (sum>9&&sum<100000){
            long sumLoc = 0;
            counter++;
            while (digit != 0)
            {
                sumLoc += (digit % 10);
                digit /= 10;
            }
            digit = sumLoc;
            sum = digit;
        }

        System.out.print(counter);
    }

}


package com.company;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String digit = in.nextLine();
        int counter = 0;

        while(digit.length() > 1) {
            int sum = 0;
            for (int i = 0; i < digit.length(); i++) {
                int numeral = Character.getNumericValue(digit.charAt(i));
                sum += numeral;
            }
            digit =Integer.toString(sum);
            counter++;
        }
        System.out.print(counter);
    }
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long digit = in.nextLong();
        int counter = 0;
        long sum = digit;
        while (sum>9&&sum<10000000){
            long sumLoc = 0;
            counter++;
            while (digit != 0)
            {
                sumLoc += (digit % 10);
                digit /= 10;
            }
            digit = sumLoc;
            sum = digit;
        }

        System.out.print(counter);
    }

}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long digit = in.nextLong();
        long counter = 0;
        long sum = digit;
        while (sum>9){
            long sumLoc = 0;
            counter++;
            while (digit != 0)
            {
                sumLoc += (digit % 10);
                digit /= 10;
            }
            digit = sumLoc;
            sum = digit;
        }

        System.out.print(counter);
    }

}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double digit = in.nextDouble();
        int counter = 0;
        double sum = digit;
        while (sum>9){
            double sumLoc = 0;
            counter++;
            while (digit != 0)
            {
                sumLoc += (digit % 10);
                digit /= 10;
            }
            digit = sumLoc;
            sum = digit;
        }

        System.out.print(counter);
    }

}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String digit = in.nextLine();
        int counter = 0;

        while(digit.length() > 1) {
            int sum = 0;
            for (int i = 0; i < digit.length(); i++) {
                int numeral = Character.getNumericValue(digit.charAt(i));
                sum += numeral;
            }
            digit =Integer.toString(sum);
            counter++;
        }
        System.out.print(counter);
    }
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int digit = in.nextLong();
        if ((digit>=0)&&(digit<=Math.pow(10,100000))) {
            int counter = 0;
            int sum = digit;
            while (sum > 9) {
                int sumLoc = 0;
                counter++;
                while (digit != 0) {
                    sumLoc += (digit % 10);
                    digit /= 10;
                }
                digit = sumLoc;
                sum = digit;
            }

            System.out.print(counter);
        }
    }
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{

	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		String ip = sc.next();
		int count =0;
		long sum = 11;
		if(ip.length()<2)
		{
		    System.out.print("0");
		}
		else
		{
		while(sum>=10)
		{
		    sum = 0;
		    for(int i=0;i<ip.length();i++)
		    {
		     sum += Character.getNumericValue(ip.charAt(i));
		    }
		    ip = String.valueOf(sum);
		    count++;
		}
		System.out.print(count);
		}
    }
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{

	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		String ip = sc.next();
		int count =0;
		int sum = 11;
		if(ip.length()<2)
		{
		    System.out.print("0");
		}
		else
		{
		while(sum>10)
		{
		    sum = 0;
		    for(int i=0;i<ip.length();i++)
		    {
		     sum += a;
		    }
		    ip = String.valueOf(sum);
		    count++;
		}
		System.out.print(count);
		}
    }
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{

	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		String ip = sc.next();
		int count =0;
		int sum = 11;
		if(ip.length()<2)
		{
		    System.out.print("0");
		}
		else
		{
		while(sum>10)
		{
		    sum = 0;
		    for(int i=0;i<ip.length();i++)
		    {
		     sum += ip.charAt(i);
		    }
		    ip = String.valueOf(sum);
		    count++;
		}
		System.out.print(count);
		}
    }
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{

	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		String ip = sc.next();
		int count =0;
		long sum = 11;
		if(ip.length()<2)
		{
		    System.out.print("0");
		}
		else
		{
		while(sum>10)
		{
		    sum = 0;
		    for(int i=0;i<ip.length();i++)
		    {
		     sum += Character.getNumericValue(ip.charAt(i));
		    }
		    ip = String.valueOf(sum);
		    count++;
		}
		System.out.print(count);
		}
    }
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{

	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		String ip = sc.next();
		int count =0;
		long sum = 11;
		if(ip.length()<2)
		{
		    System.out.print("0");
		}
		else
		{
		while(sum>10)
		{
		    sum = 0;
		    for(int i=0;i<ip.length();i++)
		    {
		     sum += ip.charAt(i);
		    }
		    ip = String.valueOf(sum);
		    count++;
		}
		System.out.print(count);
		}
    }
}


import java.util.*;

public class Main
{
	public static void main(String[] args) {
		int num=0,count=0;
		Scanner sc = new Scanner(System.in);
		num = sc.nextInt();
		if(num == 0)
		System.out.println("0");
		else if(num > 0)
		{
		    while(num>=9)
		    {
		        num = num/10;
		        count++;
		    }
		}
		System.out.println(count);
	}
}


import java.util.*;
import java.lang.*;

public class Main
{
	public static void main(String[] args) {
		int count=0,sum=0;

		Scanner sc = new Scanner(System.in);
		char ch[]=sc.next().toCharArray();

		if(ch.length==1)
		{
		    System.out.println("0");
		}
		else
		{
		    for(int i=0;i<ch.length;i++)
		    {
		        sum+=(ch[i]-48);
		    }
		    count = 1;
		    while(sum>9)
		    {
		        int n=sum;
		        sum =0;
		        while(n!=0)
		        {
		            sum+=n%10;
		            n/=10;
		        }
		        count++;
		    }System.out.println(count);
		}

	}
}


import java.util.*;

public class Main
{
	public static void main(String[] args) {
		int num=0,count=0;
		Scanner sc = new Scanner(System.in);
		num = sc.nextInt();
		if(num > 0)
		{
		    while(num>=9)
		    {
		        num = num/10;
		        count++;
		    }
		}
		System.out.println(count);
	}
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        long  n=scan.nextLong();
        //System.out.println(Func.amount(n));
        //System.out.println(Func.Sum(n));
        int otvet=0;
        while(Func.amount(n)!=1){
            n=Func.Sum(n);
            otvet++;
        }
        System.out.println(otvet);

    }

}

class Func {
    static int amount(long n){
        int kol=0;
        if (n==0)
            return 1;
        while(n>0){
            n/=10;
            kol++;
        }
        return kol;
    }

    static long Sum(long n){
        long sum=0;
        while(n>0){
            sum+=n%10;
            n/=10;
        }
        return sum;
    }

}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        //System.out.println(Func.amount(n));
        //System.out.println(Func.Sum(n));
        int otvet=0;
        while(Func.amount(n)!=1){
            n=Func.Sum(n);
            otvet++;
        }
        System.out.println(otvet);

    }

}

class Func {
    static int amount(int n){
        int kol=0;
        if (n==0)
            return 1;
        while(n>0){
            n/=10;
            kol++;
        }
        return kol;
    }

    static int Sum(int n){
        int sum=0;
        while(n>0){
            sum+=n%10;
            n/=10;
        }
        return sum;
    }

}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        String  n=scan.nextLine();

        int otvet=0;
        while(Func.amount(n)!=1){
            n=Func.Sum(n);
            otvet++;
        }
        System.out.println(otvet);

    }

}

class Func {
    static int amount(String n){
        return n.length();
    }

    static String Sum(String n){
        long sum=0L;
        for(int i=0; i<n.length(); i++)
            sum+=(int)n.charAt(i)-48;

        String res;
        res=sum+"";
        return res;
    }

}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        long  n=scan.nextInt();
        //System.out.println(Func.amount(n));
        //System.out.println(Func.Sum(n));
        int otvet=0;
        while(Func.amount(n)!=1){
            n=Func.Sum(n);
            otvet++;
        }
        System.out.println(otvet);

    }

}

class Func {
    static int amount(long n){
        int kol=0;
        if (n==0)
            return 1;
        while(n>0){
            n/=10;
            kol++;
        }
        return kol;
    }

    static long Sum(long n){
        long sum=0;
        while(n>0){
            sum+=n%10;
            n/=10;
        }
        return sum;
    }

}


import java.io.IOException;
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        String s=sc.nextLine();
        int count=0;
        for (int i=0;i<s.length();i++){
            if (s.charAt(i)!=0)count++;
        }
        System.out.println(count);

    }
}


import java.io.IOException;
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        int count=0;
        for (int i=0;i<s.length();i++){
            if (s.charAt(i)!='0')count++;
        }
        System.out.println(count);

    }
}


import java.io.IOException;
import java.io.*;
import java.util.*;
public class Cp {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        int count=0;
       while (s.length()!=1){
           int sum=0;
           for (int i=0;i<s.length();i++){
               sum+=Integer.parseInt(String.valueOf(s.charAt(i)));
           }
           count++;
//           s=String.valueOf(sum);
           s=Integer.toString(sum);
       }
        System.out.println(count);

    }
}


import java.io.*;
import java.util.*;

public class A1008 {
    public static void main(String [] args) /*throws Exception*/ {
        InputStream inputReader = System.in;
        OutputStream outputReader = System.out;
        InputReader in = new InputReader(inputReader);//new InputReader(new FileInputStream(new File("input.txt")));new InputReader(inputReader);
        PrintWriter out = new PrintWriter(outputReader);//new PrintWriter(new FileOutputStream(new File("output.txt")));
        Algorithm solver = new Algorithm();
        solver.solve(in, out);
        out.close();
    }
}

class Algorithm {
    void solve(InputReader ir, PrintWriter pw) {

        String n = ir.next();
        int sum = 0;
        int count = 0;
        char [] numbers = n.toCharArray();

        while (numbers.length != 1) {
            for (int i = 0; i < numbers.length; i++) {
                sum += Character.getNumericValue(numbers[i]);
            }
            n = "" + sum;
            sum = 0;
            count++;
            numbers = n.toCharArray();
        }

        pw.print(count);

    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    String nextLine(){
        String fullLine = null;
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                fullLine = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return fullLine;
        }
        return fullLine;
    }

    String [] toArray() {
        return nextLine().split(" ");
    }

    int nextInt() {
        return Integer.parseInt(next());
    }
    double nextDouble() {
        return Double.parseDouble(next());
    }
    long nextLong() {
        return Long.parseLong(next());
    }

}


import java.io.*;
import java.util.*;

public class A1008 {
    public static void main(String [] args) /*throws Exception*/ {
        InputStream inputReader = System.in;
        OutputStream outputReader = System.out;
        InputReader in = new InputReader(inputReader);//new InputReader(new FileInputStream(new File("input.txt")));new InputReader(inputReader);
        PrintWriter out = new PrintWriter(outputReader);//new PrintWriter(new FileOutputStream(new File("output.txt")));
        Algorithm solver = new Algorithm();
        solver.solve(in, out);
        out.close();
    }
}

class Algorithm {
    void solve(InputReader ir, PrintWriter pw) {

        String n = ir.next();
        int sum = 0, len = n.length();
        int count = 0;
        char [] numbers = n.toCharArray();

        while (len != 1) {
            for (int i = 0, num; i < len; i++) {
                num = numbers[i] - 48;
                sum += num;
            }
            n = "" + sum;
            len = n.length();
            sum = 0;
            count++;
            numbers = n.toCharArray();
        }

        pw.print(count);

    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    String nextLine(){
        String fullLine = null;
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                fullLine = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return fullLine;
        }
        return fullLine;
    }

    String [] toArray() {
        return nextLine().split(" ");
    }

    int nextInt() {
        return Integer.parseInt(next());
    }
    double nextDouble() {
        return Double.parseDouble(next());
    }
    long nextLong() {
        return Long.parseLong(next());
    }

}


import java.io.*;
import java.util.*;

public class A1008 {
    public static void main(String [] args) /*throws Exception*/ {
        InputStream inputReader = System.in;
        OutputStream outputReader = System.out;
        InputReader in = new InputReader(inputReader);//new InputReader(new FileInputStream(new File("input.txt")));new InputReader(inputReader);
        PrintWriter out = new PrintWriter(outputReader);//new PrintWriter(new FileOutputStream(new File("output.txt")));
        Algorithm solver = new Algorithm();
        solver.solve(in, out);
        out.close();
    }
}

class Algorithm {
    void solve(InputReader ir, PrintWriter pw) {

        String n = ir.next();
        int sum = 0, len = n.length();
        int count = 0;
        char [] numbers = n.toCharArray();

        while (len != 1) {
            for (int i = 0, num; i < len; i++) {
                num = Character.getNumericValue(numbers[i]);
                sum += num;
            }
            n = "" + sum;
            len = n.length();
            sum = 0;
            count++;
            numbers = n.toCharArray();
        }

        pw.print(count);

    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    String nextLine(){
        String fullLine = null;
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                fullLine = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return fullLine;
        }
        return fullLine;
    }

    String [] toArray() {
        return nextLine().split(" ");
    }

    int nextInt() {
        return Integer.parseInt(next());
    }
    double nextDouble() {
        return Double.parseDouble(next());
    }
    long nextLong() {
        return Long.parseLong(next());
    }

}


import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author pc corner
 */
public class JavaApplication16 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       String n =sc.next();
        if(Integer.parseInt(n)<=9){
            System.out.println(0);
             return;
        }
        System.out.println(sum(0,n));

    }
    private static  int sum(int count,String n){
        int sum=0;
        for(int i=0;i<n.length();i++)
        {sum+=(n.charAt(i)-'0');

        }
       // System.out.println(sum+"   "+count);
        count++;
        if(sum<=9){
           return count;
        }
       return  sum(count,sum+"");
    }

}


import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author pc corner
 */
public class JavaApplication16 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       String n =sc.next();
        if(n.length()==1){
            System.out.println(0);
             return;
        }
        System.out.println(sum(0,n));

    }
    private static  int sum(int count,String n){
        long sum=0;
        for(int i=0;i<n.length();i++)
        {sum+=(n.charAt(i)-'0');

        }
       // System.out.println(sum+"   "+count);
        count++;
        if(sum<=9){
           return count;
        }
       return  sum(count,sum+"");
    }

}


import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author pc corner
 */
public class JavaApplication16 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       String n =sc.next();
        if(Integer.parseInt(n)<=9){
            System.out.println(0);
             return;
        }
        System.out.println(sum(0,n));

    }
    private static  int sum(int count,String n){
        long sum=0;
        for(int i=0;i<n.length();i++)
        {sum+=(n.charAt(i)-'0');

        }
       // System.out.println(sum+"   "+count);
        count++;
        if(sum<=9){
           return count;
        }
       return  sum(count,sum+"");
    }

}


import java.util.Scanner;
public class SumDigits  {
    public static void main(String[]args)   {
        Scanner input = new Scanner(System.in);
        long num = input.nextLong();
        int i = 0;
        while(num / 10 != 0)    {
            num = sumDigits(num);
            i++;
        }
        System.out.println(i);
    }

    public static long sumDigits(long num)  {
        long sum = 0;
        while(num != 0) {
            sum += num % 10;
            num /= 10;
        }
        return sum;
    }
}


import java.util.Scanner;
public class SumOfDigits {
	public static void main(String[]args) {
		Scanner input = new Scanner(System.in);
		String num = input.next();
		int i = 0;
		while(num.length() > 1)	{
			num = sumDigits(num);
			i++;
			}
		System.out.println(i);
		}

	public static String sumDigits(String num) {
		long sum = 0;
		for(int i = 0; i < num.length(); i++)
			sum += Integer.parseInt(num.charAt(i) + "");
		return sum + "";
		}
	}


import java.util.Scanner;
import java.math.*;

public class SumOfDigits {
    public static void main(String[]args)   {
        Scanner input = new Scanner(System.in);
        BigInteger num = new BigInteger(input.next());
        int i = 0;
        while(!(num.divide(BigInteger.TEN)).equals(BigInteger.ZERO))    {
            num = sumDigits(num);
            i++;
        }
        System.out.println(i);
    }

    public static BigInteger sumDigits(BigInteger num)  {
        BigInteger sum = BigInteger.ZERO;
        while(!num.equals(BigInteger.ZERO)) {
            sum = sum.add(num.remainder(BigInteger.TEN));
            num = num.divide(BigInteger.TEN);
        }
        return sum;

    }

}


import java.util.*;
import java.lang.*;
import java.math.*;

public class MyClass {
    public static void main(String args[]) {
     Scanner sc =new Scanner(System.in);

String s = sc.nextLine();
int n =s.length();
int ans=0;
int time=1;

for(int i=0; i<n; i++){
    ans+=s.charAt(i)-'0';
}
if(n<2)
time=0;
while(ans/10!=0){
    time++;
    int sum;
    for(sum=0; ans>0; sum+=ans%10,ans/=10);
    ans=sum;
}
System.out.println(time);
    }
}


import java.util.*;
import java.lang.*;
import java.math.*;

public class MyClass {
    public static void main(String args[]) {
     Scanner sc =new Scanner(System.in);

String s = sc.nextLine();
int n =s.length();
int ans=0;
for(int i=0; i<n; i++){
    ans+=s.charAt(i)-'0';
    if(ans>=10){
        int temp=ans%10;
        ans/=10;
        ans+=temp;
    }
}
System.out.println(ans);
    }
}


import java.util.*;
import java.lang.*;
import java.math.*;

public class MyClass {
    public static void main(String args[]) {
     Scanner sc =new Scanner(System.in);

String s = sc.nextLine();
int n =s.length();
int ans=0;
int time=1;

for(int i=0; i<n; i++){
    ans+=s.charAt(i)-'0';
}
if(ans==0)
time=0;
while(ans/10!=0){
    time++;
    int sum;
    for(sum=0; ans>0; sum+=ans%10,ans/=10);
    ans=sum;
}
System.out.println(time);
    }
}


import java.util.*;
import java.lang.*;
import java.math.*;

public class MyClass {
    public static void main(String args[]) {
     Scanner sc =new Scanner(System.in);

String s = sc.nextLine();
int n =s.length();
int ans=0;
int time=1;

for(int i=0; i<n; i++){
    ans+=s.charAt(i)-'0';
}
while(ans/10!=0){
    time++;
    int sum;
    for(sum=0; ans>0; sum+=ans%10,ans/=10);
    ans=sum;
}
System.out.println(time);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String x = br.readLine();
			int counter = 0;

			long aux = 0;
			if(19<x.length()) {
				for (int i = 0; i < args.length; i++) {
					aux+=Long.parseLong(""+ x.charAt(i));
				}
				x = Long.toString(aux);

			}

			while(Long.parseLong(x)>9) {

				long sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum += Long.parseLong(""+x.charAt(i));
				}
				counter++;
				x = Long.toString(sum);

			}

			System.out.println(counter);

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String x = br.readLine();
			int counter = 0;

			long aux = 0;
			if(2<=x.length()) {
				for (int i = 0; i < x.length(); i++) {
					aux += Long.parseLong("" + x.charAt(i));
				}
				x = Long.toString(aux);
				counter++;
			}

			while (Long.parseLong(x) > 9) {

				long sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum += Long.parseLong("" + x.charAt(i));
				}
				counter++;
				x = Long.toString(sum);

			}

			System.out.println(counter);

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String x = br.readLine();
			int counter = 0;

			while(Integer.parseInt(x)>9) {

				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum += Integer.parseInt(""+x.charAt(i));
				}
				counter++;
				x = Integer.toString(sum);

			}

			System.out.println(counter);

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String x = br.readLine();
			int counter = 0;

			while(Long.parseLong(x)>9) {

				long sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum += Long.parseLong(""+x.charAt(i));
				}
				counter++;
				x = Long.toString(sum);

			}

			System.out.println(counter);

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}


import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])
    {
        Scanner scan = new Scanner(System.in);
        int count =0;

        char arr[] = scan.next().toCharArray();
        if(Integer.parseInt(new String(arr))<10)
        {
            System.out.println("0");
            return ;
        }

        for(int i=0;i<arr.length;i++)
        {
            count+=arr[i]-'0';
        }
        int ans =1;
        while(count>9)
        {
            ans++;
            int val = count ;
            int sum = 0;
            while(val!=0)
            {
                sum+=val%10;
                val = val/10;
            }
            count = sum ;
        }
        System.out.println(ans);

    }
}


import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])
    {
        Scanner scan = new Scanner(System.in);
        int count =0;
        char arr[] = scan.next().toCharArray();
        for(int i=0;i<arr.length;i++)
        {
            count+=arr[i]-'0';
        }
        int ans =1;
        while(count>9)
        {
            ans++;
            int val = count ;
            int sum = 0;
            while(val!=0)
            {
                sum+=val%10;
                val = val/10;
            }
            count = sum ;
        }
        System.out.println(ans);

    }
}


import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])
    {
        Scanner scan = new Scanner(System.in);
        int count =0;
        char arr[] = scan.next().toCharArray();
        if(arr.length==1)
        {
            System.out.println("0");
            return ;
        }

        for(int i=0;i<arr.length;i++)
        {
            count+=arr[i]-'0';
        }
        int ans =1;
        while(count>9)
        {
            ans++;
            int val = count ;
            int sum = 0;
            while(val!=0)
            {
                sum+=val%10;
                val = val/10;
            }
            count = sum ;
        }
        System.out.println(ans);

    }
}


import java.util.Scanner;

public class SumOfDigit {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s=scan.nextLine();
		if(s=="0") System.out.println(s);
		else
		{
			s=s.replace("0","");
			System.out.println(s.length());
		}

	}

}


import java.util.Scanner;

public class SumOfDigit {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s=scan.nextLine();
		int n=s.length();
		int c=0;
		while(n>1)
		{
			int sum=0;
			for(int i=0;i<n;i++)
			{
				sum+=s.charAt(i)-'0';
			}
			s=Integer.toString(sum);
			n=s.length();
			c++;
		}

		System.out.println(c);
	}

}


import java.util.Scanner;

public class SumOfDigit {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s=scan.nextLine();
		if(s=="0") System.out.println(s);
		else
		{
			s=s.replace("0","");
			if(s.length()>=9) System.out.println("2");
			else System.out.println(s.length());
		}

	}

}


import java.util.Scanner;

public class SumOfDigit {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s=scan.nextLine();
		if(s=="0") System.out.println(s);
		else
		{
			s=s.replace("0","");
			if(s.length()==9) System.out.println("2");
			else System.out.println(s.length());
		}

	}

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.*;
import java.util.*;
import java.util.InputMismatchException;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Main1 solver = new Main1();
        solver.solve(1, in, out);
        out.close();
    }

    static class Main1{
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int n=s.nextInt(), count=0;
            while(n>9){
                int sum=0;
                while(n>0){
                    sum+=n%10;
                    n/=10;
                }
                n=sum;
                count++;
            }
            out.println(count);

		out.close();
        }
    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        String num = sc.next();
        int sum;
        int count = 0;
        while(true){
            sum = 0;
            if(num.length() == 1){
                System.out.println(count);
                break;
            }
            else{

                for (int i = 0; i < num.length(); i++) {
                    sum+=Integer.parseInt(num.charAt(i)+"");
                }
            }
            num = sum+"";
            count++;
        }

    }

}


import java.io.BufferedReader;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main{

    public static PrintWriter out;

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());

                } catch (IOException e) {
                    e.printStackTrace();

                }

            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try{
                str = br.readLine();
            } catch (IOException e){
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        MyScanner s = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=s.nextInt();
        singsum(n);

        out.close();

    }
    static int count=0;
    public static void singsum(int n){
        if(n<10) { System.out.println(count); return; }
        int z=n;
        int sum=0;
        while(z!=0){
            sum=sum+z%10;
            z=z/10;
        }
        count++;
        singsum(sum);

    }
}