#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,ln,t,k,nn;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
ln=LLONG_MIN;
for (i=1; i<=n; i++) ln=max(ln,a[i]);
cout<<"So lon nhat la: "<<ln<<endl;
cout<<"VI tri la: ";
for (i=1; i<=n; i++) if (ln==a[i]) cout<<i<<" ";
cout<<endl;
t=0;
for (i=1; i<=n; i++)
if (a[i]>0) t+=a[i];
cout<<"Tong cac so duong la: "<<t<<endl;
cin>>k;
for (i=1; i<=n; i++)
if (a[i]%k==0) cout<<a[i]<<" ";
cout<<endl;
nn=LLONG_MAX;
for (i=1; i<=n; i++)
nn=min(nn,a[i]);
cout<<nn;
return 0;
}