CodeForces 104 B 猜答案


Time Limit: 2000MS Memory Limit: 262144KB 64bit IO Format: %I64d& %I64u

[Submit [GoBack  [Status]

Description

The average miner Vaganych took refresher courses. As soon as aminer completes the courses, he should take exams. The hardest oneis a computer test called "Testing Pants for Sadness".

The test consists of n questions; thequestions are to be answered strictly in the order in which theyare given, from question 1 toquestion n.Question icontains ai answervariants, exactly one of them is correct.

A click is regarded as selecting any answer in any question. Thegoal is to select the correct answer for each ofthe n questions. IfVaganych selects a wrong answer for some question, then allselected answers become unselected and the test starts from thevery beginning, from question 1 again. But Vaganychremembers everything. The order of answers for each question andthe order of questions remain unchanged, as well as the questionand answers themselves.

Vaganych is very smart and his memory is superb, yet he isunbelievably unlucky and knows nothing whatsoever about the test'stheme. How many clicks will he have to perform in the worstcase?

Input

The first line contains a positiveinteger n (1 ≤ n ≤ 100). Itis the number of questions in the test. The second line containsspace-separated n positiveintegersai (1 ≤ ai ≤ 109), the number of answer variants toquestion i.

Output

Print a single number — the minimal number of clicks needed topass the test it the worst-case scenario.

Please do not use the %lld specificator to read or write 64-bitintegers in С++. It is preferred to use the cin, cout streams orthe %I64d specificator.

Sample Input

Input
2

1 1

Output
2
Input
2

2 2

Output
5
Input
1

10

Output
10

Hint

Note to the second sample. In the worst-case scenario you willneed five clicks:

  • the first click selects the first variant to the firstquestion, this answer turns out to be wrong.
  • the second click selects the second variant to the firstquestion, it proves correct and we move on to the secondquestion;
  • the third click selects the first variant to the secondquestion, it is wrong and we go back to question 1;
  • the fourth click selects the second variant to the firstquestion, it proves as correct as it was and we move on to thesecond question;
  • the fifth click selects the second variant to the secondquestion, it proves correct, the test is finished.

[Submit [GoBack  [Status]

#include<iostream>
#include<stdio.h>
#include<cmath>
const int MAX=105;
__int64 a[MAX];
using namespace std;
int main()
{
   int n,i;
   bool f=true;
   __int64 sum,temp;
   while(scanf("%d",&n)!=EOF)
   {
           
           
      scanf("%I64d",&a[1]); 
         if(n==1) { printf("%I64d\n",a[1]);continue;}
         sum=a[1];
           for(i=2;i<=n;i++)
           {
                  scanf("%I64d",&a[i]);
          temp=a[i]+(a[i]-1)*(i-1);
                   sum+=temp;
           }
       printf("%I64d\n",sum);
   }
return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值