#44304: cpp解


11331076@stu.tshs.tp.edu.tw (sky)


#include <iostream>
#include <vector>
using namespace std;

int main() {
    int firstline, a, b;
    cin >> firstline;  

    vector<int> prices(firstline);  

    
    for (int i = 0; i < firstline; i++) {
        cin >> prices[i];  
    }

    int totalmoney = 0;
    
    
    while (cin >> a >> b) {
        if (a == 0 && b == 0) {
            break; 
        }
        totalmoney += prices[a - 1] * b;  
    }   

cout << totalmoney << endl;

    return 0;
}