text: #include <iostream>
  #include <vector>
  
  template <typename T>
  std::istream& operator >>(std::istream& input, std::vector<T>& v)
  {
      for (T& a : v)
          input >> a;
  
      return input;
  }
  
  void answer(unsigned v)
  {
      std::cout << v << '\n';
  }
  
  void solve(const std::vector<unsigned>& a)
  {
      const size_t n = a.size();
  
      unsigned k = 0;
      for (size_t i = 0; i < n; ++i)
          k += a[i] * 2 * i;
  
      answer(2 * k);
  }
  
  int main()
  {
      size_t n;
      std::cin >> n;
  
      std::vector<unsigned> a(n);
      std::cin >> a;
  
      solve(a);
  
      return 0;
  }
  
  