Language: C++

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

int solve(int A[], int n, int minw) {
	int cnt = 0;
	int B[n], T[10001];
	bool V[n];
	for (int i = 0; i < n; i++) {
		B[i] = A[i];
		V[i] = false;
	}

	sort(B, B + n);
	for (int i = 0; i < n; i++) {
		T[B[i]] = i; //?????????????????????????????§?????????????????????????????????????????????
	}
	for (int i = 0; i < n; i++)	{
		if (V[i]) continue;
		int cur = i, S = 0, m = 10000, an = 0;
		while(1) {
			V[cur] = true; //????????????
			an++;???//?°???°?????????????????°
			int v = A[cur];???
			m = min(m, v); //?°???°???????????????????°????
			S += v; //????????????
			cur = T[v]; //??¬??\??????????????\????????????
			if (V[cur]) break; //????????????????????????????????????
		}
		cnt += min(S + (an - 2) * m, S + m + (an + 1) * minw); //????????§????????????while????????§??£?¨?
	}
	return cnt;
}

int main() {
	int n;
	cin >> n;
	int A[n];
	int minw = 10000;
	for (int i = 0; i < n; i++)	{
		cin >> A[i];
		minw = min(minw, A[i]);
	}

	int min = solve(A, n, minw);

	cout << min << endl;

	return 0;
}

Compiler output:
a.cc:23:31: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]
   23 |                         an++;???//?°???°?????????????????°
a.cc: In function 'int solve(int*, int, int)':
a.cc:23:30: error: expected primary-expression before '?' token
   23 |                         an++;???//?°???°?????????????????°
      |                              ^
a.cc:23:31: error: expected primary-expression before '?' token
   23 |                         an++;???//?°???°?????????????????°
      |                               ^
a.cc:23:32: error: expected primary-expression before '?' token
   23 |                         an++;???//?°???°?????????????????°
      |                                ^
a.cc:24:25: error: expected primary-expression before 'int'
   24 |                         int v = A[cur];???
      |                         ^~~
a.cc:23:33: error: expected ':' before 'int'
   23 |                         an++;???//?°???°?????????????????°
      |                                 ^
      |                                 :
   24 |                         int v = A[cur];???
      |                         ~~~      
a.cc:24:25: error: expected primary-expression before 'int'
   24 |                         int v = A[cur];???
      |                         ^~~
a.cc:23:33: error: expected ':' before 'int'
   23 |                         an++;???//?°???°?????????????????°
      |                                 ^
      |                                 :
   24 |                         int v = A[cur];???
      |                         ~~~      
a.cc:24:25: error: expected primary-expression before 'int'
   24 |                         int v = A[cur];???
      |                         ^~~
a.cc:23:33: error: expected ':' before 'int'
   23 |                         an++;???//?°???°?????????????????°
      |                                 ^
      |                                 :
   24 |                         int v = A[cur];???
      |                         ~~~      
a.cc:24:25: error: expected primary-expression before 'int'
   24 |                         int v = A[cur];???
      |                         ^~~
a.cc:24:40: error: expected primary-expression before '?' token
   24 |                         int v = A[cur];???
      |                                        ^
a.cc:24:41: error: expected primary-expression before '?' token
   24 |                         int v = A[cur];???
      |                                         ^
a.cc:24:42: error: expected primary-expression before '?' token
   24 |                         int v = A[cur];???
      |                                          ^
a.cc:25:36: error: 'v' was not declared in this scope
   25 |                         m = min(m, v); //?°???°???????????????????°????
      |                                    ^
a.cc:25:38: error: expected ':' before ';' token
   25 |                         m = min(m, v); //?°???°???????????????????°????
      |                                      ^
      |                                      :
a.cc:25:38: error: expected primary-expression before ';' token
a.cc:25:38: error: expected ':' before ';' token
   25 |                         m = min(m, v); //?°???°???????????????????°????
      |                                      ^
      |                                      :
a.cc:25:38: error: expected primary-expression before ';' token
a.cc:25:38: error: expected ':' before ';' token
   25 |                         m = min(m, v); //?°???°???????????????????°????
      |                                      ^
      |                                      :
a.cc:25:38: error: expected primary-expression before ';' token