func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     vector<int> w(n);     for (int i = 0; i < n; i++) cin >> w[i];     int x = 0;     vector<int> ord(n);     vector<int> rd(m);     vector<bool> put(n, false);     for (int i = 0; i < m; i++) {       cin >> rd[i];       rd[i]--;       if (put[rd[i]])         continue;       else {         ord[x] = rd[i];         put[rd[i]] = true;         x++;       }     }     for (int i = 0; i < n; i++) {       if (!put[i]) {         ord[x] = i;         x++;       }     }     int lift = 0;     for (int i = 0; i < m; i++) {       int in = 0;       for (int j = 0; j < n; j++) {         if (ord[j] == rd[i]) {           in = j;         }       }       for (int j = in; j > 0; j--) {         ord[j] = ord[j - 1];         lift += w[ord[j]];       }       ord[0] = rd[i];     }     cout << lift << endl;   }   