func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m, d[210000];   long long cnt[210000];   long long solve() {     cnt[1] *= 2;     cnt[n] *= 2;     int Min = cnt[1], Max = cnt[1];     for (int i = 1; i <= n; ++i) {       if (Min > cnt[i])         Min = cnt[i];       else if (Max < cnt[i])         Max = cnt[i];     }     if (Min == Max) {       for (int i = 2; i <= n; ++i)         if (d[i] - d[i - 1] != d[2] - d[1]) return -1;       return cnt[1] * (d[n] - d[1]) - d[2] + d[1];     } else {       long long temp = 0;       for (int i = 1; i < n; ++i) {         temp += (d[i + 1] - d[i]) * min(cnt[i], cnt[i + 1]);       }       return temp;     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d , &d[i]);     scanf( %d , &m);     for (int i = 1; i <= m; ++i) {       int temp;       scanf( %d , &temp);       ++cnt[temp];     }     printf( %I64d n , solve());     return 0;   }   