//qf
#include <bits/stdc++.h>
#define f(i,j,n) for(register int i=j;i<=n;i++)
using namespace std;
typedef long long ll;
inline ll read() {
ll x=0;
int f=1;
char ch=getchar();
while(!isdigit(ch)) {
if(ch=='-') f=-1;
ch=getchar();
}
while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch-48),ch=getchar();
return x*f;
}
double a,b,c,d,x;
inline double pow(int k){
double ans=1;
while(k--) ans*=x;
return ans;
}
signed main() {
cin>>x>>a>>b>>c>>d;
cout<<fixed<<setprecision(7)<<a*pow(3)+b*pow(2)+c*pow(1)+d<<endl;
return 0;
}