#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
int a, x;
while(cin>>a){
int res = 0;
for(int i = 0; i < 5; i++){
cin>>x;
if(x < a) res += x;
}
cout<<res<<endl;
}
return 0;
}