#include <bits/stdc++.h>
using namespace std;
// #Placement
int calc(int h, int x, int y,int &energy){
int climb=0;
int drinks=0;
while(climb<h){
if(energy==0){
drinks++;
energy=5;
}
climb+=x;
if(climb>=h){
energy--;
break;
}
climb-=y;
energy--;
}
}
int main()
{
int x,y;
cin>>x>>y;
int n;
cin>>n;
int CP=7,SP=8*40;
int drinks=0;
int energy=5;
while(n--){
int h;
cin>>h;
drinks+=calc(h,x,y,energy);
}
float profit=(SP*n)-(CP*drinks);
cout<<profit<<endl;
return 0;
}