#include<bits/stdc++.h>using namespace std;ifstream in("input.txt");ofstream out("output.txt");typedef long long ll;typedef string str;typedef char chr;#define save1 in.close()#define save2 out.close()#define bs bitset#define opt1 ios_base::sync_with_stdio(0)#define opt2 cin.tie(0)#define opt3 cout.tie(0)#define fi first#define se second#define vi vector<int>#define pii pair<int,int>#define pil pair<int,ll>#define pli pair<ll,int>#define pll pair<ll,ll>#define MP make_pair#define pb push_backdouble v[105];int main(){int n,a,b,i;double sum=0,a1=0;opt1;opt2;opt3;cin>>a>>b>>n;a1=a;--a;for(i=1;i<=n;++i) cin>>v[i];sort(v+1,v+n+1);sum=v[1];i=2;while(a) {if(v[i]!=v[i-1]) --a,sum+=v[i]; ++i;}cout<<floor(sum/a1)<<" ";i=n-1;a1=b;--b;sum=v[n];while(b) {if(v[i]!=v[i+1]) sum+=v[i],--b; --i;}cout<<floor(sum/a1);save1;save2;return 0;}