#include <bits/stdc++.h>
using namespace std;
int a,b=105;

int main()
{
	cin>>b;
	for(int i=1;i<=3;i++)
		cin>>a,b=min(b,a);
	cout<<b<<endl;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 		
  		long long N ,S,T,U,U2,T2,V;
  		cin >> N ;
  		U = 0;
  		V = 0;
  		T2 = 0;
  		vector<long long> vec1(N);
		
 		
  		for (long long i = 0 ; i < N ; i++){
          cin >> vec1.at(i);
          T = vec1.at(i) * vec1.at(i) * (N - 1 - i);
          T2 = T2 + T;
        }
  		
  		for (long long j = 1; j < N ; j++){
          S = vec1.at(j) * vec1.at(j);
        
          U2 = 0;
          U = U + vec1.at(j-1);
          
          U2 = ( -2 ) * U * vec1.at(j);
          V = V + (S * j) + U2;           
      	}
  		
  		V = V + T2;
  
        cout << V << endl;
}