func_code_string: #include <bits/stdc++.h>   using namespace std;   long long int a[1000001];   long long int b[1000001];   bool marked[1000001];   int main() {     long long int n, i, j, k, x, y, fin_ans = 0, sum = 0;     cin >> n >> k;     a[0] = 0;     for (i = 1; i <= n; i++) {       cin >> a[i];       sum += a[i];       fin_ans += a[i - 1] * a[i];     }     fin_ans += a[n] * a[1];     for (i = 0; i < k; i++) {       cin >> x;       b[i] = x;     }     long long val = 0;     for (j = 0; j < k; j++) {       marked[b[j]] = 1;       val += a[b[j]];       long long to_mul = 0;       if (b[j] != 1 && b[j] != n) {         to_mul = sum - val - a[b[j] + 1];         if (!marked[b[j] - 1]) {           to_mul -= a[b[j] - 1];         }       }       if (b[j] == 1) {         to_mul = sum - val - a[b[j] + 1];         to_mul -= a[n];       }       if (b[j] == n) {         to_mul = sum - val;         if (!marked[b[j] - 1]) to_mul -= a[b[j] - 1];         if (!marked[1]) to_mul -= a[1];       }       fin_ans += (a[b[j]] * to_mul);     }     cout << fin_ans << endl;     return 0;   }   