#include <bits/stdc++.h>
int main() {
  long long i, j, t, n, m, max, max_i, sum, s1[111], s2[111];
  while (scanf("%lld%lld", &n, &m) != EOF) {
    memset(s1, 0, sizeof(s1));
    memset(s2, 0, sizeof(s2));
    max = 0;
    sum = 0;
    for (i = 1; i <= n; i++) {
      scanf("%lld", &s1[i]);
    }
    for (i = 1; i <= m; i++) {
      scanf("%lld", &t);
      s2[t]++;
    }
    for (i = 1; i <= n; i++) {
      for (j = i; j <= n; j++) {
        if (s1[i] > s1[j]) {
          t = s1[i];
          s1[i] = s1[j];
          s1[j] = t;
          t = s2[i];
          s2[i] = s2[j];
          s2[j] = t;
        }
      }
    }
    for (i = n; i > 0; i--) {
      if (s2[i] == 0) {
        sum += s1[i];
        s1[i] = 0;
      }
    }
    for (i = n; i > 0; i--) {
      if (s2[i] > 0) {
        if (sum == 0) {
          sum = s1[i];
          s1[i] = 0;
        } else if (sum < s1[i]) {
          sum += s1[i];
          s1[i] = 0;
        } else {
          s1[i] = sum;
          sum += s1[i];
          s1[i] = 0;
        }
      }
    }
    printf("%lld\n", sum);
  }
  return 0;
}
