/*
ID: agageld1
LANG: C++17
TASK:
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 400005
#define ff first
#define ss second
#define pb push_back
#define sz(s) (int)s.size()
#define rep(c, a, b) for(c = a; c <= b; c++)
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll n, t, T, a[N];
string s, g, h;
	vector <int> v;
int main () {
	//freopen("txt.in","r",stdin);
	//freopen("txt.out","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	bool w = 0;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		if(a[1] != a[i]) w = 1;
	}
	if(n == 1) {
		cout << a[1] << '\n';
		return 0;
	}
	if(!w) {
		while(n != 0) {
			a[1] *= 10;
			n /= 10;
		}
		cout << a[1] << '\n';
		return 0;
	}
	for(int i = 1;; i++) {
		v.clear();
		for(int j = i; j <= i+n-1; j++){
			v.pb(j);
		}
		bool tr = 0;
		for(int j = 1; j <= n; j++) {
			while(v[j-1] != 0 && (v[j - 1] % 10) != a[j]) {
				v[j-1] /= 10;
			}
			if(v[j-1] == 0 || v[j-1] % 10 != a[j]) {
				tr = 1;
				break;
			}
		}
		if(!tr) {
			cout << i << '\n';
			return 0;
		}
	}
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |