#include<cstdio>
bool vis[100010]={0};
int s[100010]={0},A[100010]={0},c[2000]={0},P[100010]={0};
int main()
{
freopen("Marshtomp.in","r",stdin);
freopen("Marshtomp.out","w",stdout);
int n,m;
scanf("%d",&n);
for (int i=1;i<=n;i++) scanf("%d",&A[i]);
scanf("%d",&m);
long long sum=0;
for (int i=1;i<=m;i++){scanf("%d",&c[i]); vis[c[i]]=1; sum=(sum+A[c[i]])% 9999997;}
long long Ans=0;
for (int i=1;i<=n;i++)
if (vis[i]==0) Ans=(Ans+Ans*A[i]+A[i])% 9999997;
long long f=Ans;
for (int i=1;i<=m;i++)
Ans=(Ans+f*A[c[i]])% 9999997;
Ans=(Ans+sum)% 9999997;
printf("%lld",Ans);
}