/* ***********************************************
Author        :Maltub
Email         :xiang578@foxmail.com
Blog          :htttp://www.xiang578.top
************************************************ */

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
//#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
using namespace std;
typedef vector<int> VI;
typedef long long ll;
const ll mod=1000000007;
const int N=2048;
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int i,j,n,k,a1,a2;
    char s[12345],a[12345];
    while(~scanf("%d%d",&n,&k))
    {
        scanf("%s",s);
        int len=strlen(s);
        for(i=0; i<len; i++)
        {
            a1=s[i]-'a';
            a2='z'-s[i];
            if(max(a1,a2)<=k)
            {
                if(a1>=a2)
                {
                    s[i]='a';
                    k-=a1;
                }
                else
                {
                    s[i]='z';
                    k-=a2;
                }
            }
            else
            {
                if(a1<k)
                {
                    s[i]=s[i]+k;
                }
                else
                {
                    s[i]=s[i]-k;
                }
                k=0;
            }
            if(k==0) break;
        }
        if(k) puts("-1");
        else printf("%s\n",s);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];
int n , k ;
string s ;
int main(){
	cin >> n >> k ;
	cin >> s ;
	for(int i = 0 ; i < s.size() ; i ++){
		a[i] = s[i] - 'A' - 31;

	}
	if(k > 25 * n){
		cout << -1 ;
		return 0 ;
	}
	int c = 0 ;
	int j = 0 ;
	while(c < k){
		int maxx = max(a[j] - 1 , 26 - a[j]);
		if(c + maxx <= k){
			if(maxx == a[j] - 1 ){
				a[j] -= maxx ;
			}
			else{
				a[j] += maxx;
			}
			c+=maxx ;
			j ++;
		}
		else
		{
			break;
		}
	}
	if(c == k){
		for(int i = 0 ; i < s.size() ; i ++){
			cout <<(char) (a[i]+'a'-1);
		}
		return 0;
	}
	if(c < k){
	a[j] += (k-c);
		for(int i = 0 ; i < s.size() ; i ++){
			cout << (char) (a[i]+'a'-1);
		}
	}

}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];
int n , k ;
string s ;
int main(){
	cin >> n >> k ;
	cin >> s ;
	for(int i = 0 ; i < s.size() ; i ++){
		a[i] = s[i] - 'A' - 31;

	}
	if(k > 25 * n){
		cout << -1 ;
		return 0 ;
	}
	int j = k / n ;
	if(k%n ==0){
		for(int i = 0 ; i < s.size() ; i ++){
		if(a[i] <= 13){
			a[i] += j;
		}
		else{
			a[i] -= j;
		}
	}
	}
	else{
		for(int i = 0 ; i < s.size() - 1 ; i ++){
		if(a[i] <= 13){
			a[i] += j;
		}
		else{
			a[i] -= j;
		}
	}
		if(a[s.size() - 1] <= 13){
			a[s.size() - 1] += ((k%n+j));
		}
		else{
			a[s.size() - 1] -= ((k%n+j));
		}
	}
	for(int i = 0 ; i < s.size() ; i ++){
		cout << (char) (a[i] + 'a' - 1) ;
	}

}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];
int n , k ;
string s ;
int main(){
	cin >> n >> k ;
	cin >> s ;
	for(int i = 0 ; i < s.size() ; i ++){
		a[i] = s[i] - 'A' - 31;

	}
	if(k > 25 * n){
		cout << -1 ;
		return 0 ;
	}
	int c = 0 ;
	int j = 0 ;
	while(c < k){
		int maxx = max(a[j] - 1 , 26 - a[j]);
		if(c + maxx <= k){
			if(maxx == a[j] - 1 ){
				a[j] -= maxx ;
			}
			else{
				a[j] += maxx;
			}
			c+=maxx ;
			j ++;
		}
		else
		{
			break;
		}
	}
	if(c == k){
		for(int i = 0 ; i < s.size() ; i ++){
			cout <<(char) (a[i]+'a'-1);
		}
		return 0;
	}
	if(c < k){
	if(a[j] + (k-c) <= 26){
		a[j] += (k-c);
	}
	else if(a[j] - (k-c) >=1){
		a[j] -= (k-c);
	}
	else{
		cout << -1 ;
		return 0;
	}
	for(int i = 0 ; i < s.size() ; i ++){
			cout << (char) (a[i]+'a'-1);
		}
	}

}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn] ,d;
int n , k ;
string s ;
int main(){
	cin >> n >> k ;
	cin >> s ;
	for(int i = 0 ; i < s.size() ; i ++){
		a[i] = s[i] - 'A' - 31;
		d += max(a[i] - 1 , 26 - a[i]);
	}
	if(k > d){
		cout << -1 ;
		return 0;
	}
	int c = 0 ;
	int j = 0 ;
	while(c < k){
		int maxx = max(a[j] - 1 , 26 - a[j]);
		if(c + maxx <= k){
			if(maxx == a[j] - 1 ){
				a[j] -= maxx ;
			}
			else{
				a[j] += maxx;
			}
			c+=maxx ;
			j ++;
		}
		else
		{
			break;
		}
	}
	if(c == k){
		for(int i = 0 ; i < s.size() ; i ++){
			cout <<(char) (a[i]+'a'-1);
		}
		return 0;
	}
	if(c < k){
	if(a[j] + (k-c) <= 26){
		a[j] += (k-c);
	}
	else if(a[j] - (k-c) >=1){
		a[j] -= (k-c);
	}
	for(int i = 0 ; i < s.size() ; i ++){
			cout << (char) (a[i]+'a'-1);
		}
	}

}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];
int n , k ;
string s ;
int main(){
	cin >> n >> k ;
	cin >> s ;
	for(int i = 0 ; i < s.size() ; i ++){
		a[i] = s[i] - 'A' - 31 ;
	}
	if(k > 25 * n){
		cout << -1 ;
		return 0 ;
	}
	int j = k / n ;
	if(k%n ==0){
		for(int i = 0 ; i < s.size() ; i ++){
		if(a[i] <= 13){
			a[i] += j;
		}
		else{
			a[i] -= j;
		}
	}
	}
	else{
		for(int i = 0 ; i < s.size() - 1 ; i ++){
		if(a[i] <= 13){
			a[i] += j;
		}
		else{
			a[i] -= j;
		}
	}
		if(a[s.size() - 1] <= 13){
			a[s.size() - 1] += ((k%n +j));
		}
		else{
			a[s.size() - 1] -= ((k%n +j));

		}
	}
	for(int i = 0 ; i < s.size() ; i ++){
		cout << (char) (a[i] + 'a') ;
	}
}


#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<char> sl;
int n,k;
cin >>n>>k;
for (int i = 0; i < n; ++i){
char c;
		cin >> c;
		sl.push_back(c);
}
for (int i = 0; i < n; ++i)
{
	if (k<=122-(int)sl[i]) {sl[i]=(char)((int)sl[i]+k); k=0; break;}
	else
	{
		k-=122-(int)sl[i];
		sl[i]='z';
	}
}
if (k>0) {cout << "-1";}
else {
for (int i = 0; i < n; ++i)
{
	cout << sl[i];
}
}
	return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<char> sl;
int n,k;
cin >>n>>k;
for (int i = 0; i < n; ++i){
char c;
		cin >> c;
		sl.push_back(c);
}
for (int i = 0; i < n; ++i)
{
	if (k<122-(int)sl[i]) {sl[i]=(char)((int)sl[i]+k); break;}
	else
	{
		k-=122-(int)sl[i];
		sl[i]='z';
	}
}
for (int i = 0; i < n; ++i)
{
	cout << sl[i];
}
	return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<char> sl;
int n,k;
cin >>n>>k;
for (int i = 0; i < n; ++i){
char c;
		cin >> c;
		sl.push_back(c);
}
for (int i = 0; i < n; ++i)
{
	if (k<122-(int)sl[i]) {sl[i]=(char)((int)sl[i]+k); break;}
	else
	{
		sl[i]='z';
		k-=122-(int)sl[i];
	}
}
for (int i = 0; i < n; ++i)
{
	cout << sl[i];
}
	return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<char> sl;
int n,k;
cin >>n>>k;
for (int i = 0; i < n; ++i){
char c;
		cin >> c;
		sl.push_back(c);
}
for (int i = 0; i < n; ++i)
{
	if ((int)sl[i]<110)
	{
	if (k<=122-(int)sl[i]) {sl[i]=(char)((int)sl[i]+k); k=0; break;}
	else
	{
		k-=122-(int)sl[i];
		sl[i]='z';
	}
	}
	else
	{
if (k<=(int)sl[i]-97) {sl[i]=(char)((int)sl[i]-k); k=0; break;}
	else
	{
		k-=(int)sl[i]-97;
		sl[i]='a';
	}
	}
}
if (k>0) {cout << "-1";}
else {
for (int i = 0; i < n; ++i)
{
	cout << sl[i];
}
}
	return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<char> sl;
int n,k;
cin >>n>>k;
for (int i = 0; i < n; ++i){
char c;
		cin >> c;
		sl.push_back(c);
}
for (int i = 0; i < n; ++i)
{
	if (k<122-(int)sl[i]) {sl[i]=(char)((int)sl[i]+k); k=0; break;}
	else
	{
		k-=122-(int)sl[i];
		sl[i]='z';
	}
}
if (k>0) {cout << "-1";}
else {
for (int i = 0; i < n; ++i)
{
	cout << sl[i];
}
}
	return 0;
}


#include <stdlib.h>
#include <stdio.h>
#include <iostream>
using namespace std;
int A[100005];
int main()
{
	int n,k,N=0;
	string s="abcdefghijklmnopqrstuvwxyz";
	char st[100005];
	scanf("%d %d\n",&n,&k);
	scanf("%s",st);
	for(int i=0;i<n;++i) {
		for(int j=0;j<26;++j)
			if(st[i]==s[j]) {
				N+=j+1;
				A[i]=j;
				break;
			}
	}
		int i=0;
		while(k>0&&i<n) {
			if(A[i]<=12) {
				k-=25-A[i];
				A[i]=25;
				if(k<0) {
					A[i]+=k;
					k=0;
					break;
				}
			}
			else {
				k-=A[i];
				A[i]=0;
				if(k<0)
				{
					A[i]-=k;
					k=0;
					break;
				}
			}
			i++;
		}
		if(k>0)
		    printf("-1");
		else
		for(i=0;i<n;++i)
        	printf("%c",s[A[i]]);
    return 0;
}


#include <stdlib.h>
#include <stdio.h>
#include <iostream>
using namespace std;

int A[1000005];

int main()
{
	int n,k,N=0;
	string s="abcdefghijklmnopqrstuvwxyz",st;
	scanf("%d %d",&n,&k);

	for(int i=0;i<n;++i)
	{
        scanf("%c",&st[i]);
		for(int j=0;j<26;++j)
			if(st[i]==s[j])
			{
				N+=j+1;
				A[i]=j;
				break;
			}
	}
	if( ( (N+k) > 25*n ) && ( (N-k) < 0 ) )
		printf("-1");
	else
	{
		int i=0;
		while(k>0)
		{
			if(A[i]<=13)
			{
				k-=25-A[i];
				A[i]=25;
				if(k<0)
				{
					A[i]+=k;
					k=0;
					break;
				}
			}
			else
			{
				k-=A[i];
				A[i]=0;
				if(k<0)
				{
					A[i]-=k;
					k=0;
					break;
				}
			}
			i++;
		}
		for(i=0;i<n;++i)
        	printf("%c",s[A[i]]);
	}
}


#include <iostream>
#include <stdio.h>
#include <numeric>
#include <queue>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <iomanip>
#include <set>
#include <queue>
#include <bitset>
#include <iomanip>
#include <map>
#include <string.h>
#include <stack>
#include <algorithm>
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define si(a) a.size()
#define M_PI 3.14159265358979323846
#define fin for(int i=0; i<n; ++i)

double polar(double a, double b){
    double res;
    res=atan2(a,b);
    if (res<0)
        res+=2*M_PI;
    return res;
}
double vec2(double x, double y, double x1, double y1){
    x=atan2(y,x);
    x1=atan2(y1,x1);
    x=fabs(x-x1);
    if (x>M_PI)
        x=2*M_PI-x;
    return x;
}
//97 122
int main() {
    ll n,k,sum=0;
    char A;
    cin>>n>>k>>A;
    int i=1;
    for (i; sum+122-A<k&&i<n; ++i){
        cout<<'z';
        sum+='z'-A;
        cin>>A;
    }
    printf("%c",A+k-sum);
    for(i; i<n; ++i){
        cin>>A;
        cout<<A;
    }

    return 0;
}


#include <iostream>
#include <stdio.h>
#include <numeric>
#include <queue>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <iomanip>
#include <set>
#include <queue>
#include <bitset>
#include <iomanip>
#include <map>
#include <string.h>
#include <stack>
#include <algorithm>
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define si(a) a.size()
#define M_PI 3.14159265358979323846
#define fin for(int i=0; i<n; ++i)

double polar(double a, double b){
    double res;
    res=atan2(a,b);
    if (res<0)
        res+=2*M_PI;
    return res;
}
double vec2(double x, double y, double x1, double y1){
    x=atan2(y,x);
    x1=atan2(y1,x1);
    x=fabs(x-x1);
    if (x>M_PI)
        x=2*M_PI-x;
    return x;
}
//97 122
int main() {
    ll n,k,sum=0;
    char A;
    string s;
    cin>>n>>k>>A;
    int i=1;
    for (i; sum+122-A<k&&i<n; ++i){
        s+="z";
        sum+='z'-A;
        cin>>A;
    }
    ll temp=A+k-sum;
    if(temp<='z'){
    s+=char(temp);
    sum=k;
    }
    for(i; i<n; ++i){
        cin>>A;
        s+=A;
    }

    if (sum<k)
        cout<<-1;
    else
        cout<<s;
    return 0;
}


#include <stdlib.h>
#include <stdio.h>
#include <iostream>
using namespace std;

int A[1000005];

int main()
{
	int n,k,N=0;
	string s="abcdefghijklmnopqrstuvwxyz",st;
	scanf("%d %d",&n,&k);

	for(int i=0;i<n;++i)
	{
        scanf("%s",&st[i]);
		for(int j=0;j<26;++j)
			if(st[i]==s[j])
			{
				N+=j+1;
				A[i]=j;
				break;
			}
	}
	if( ( (N+k) > 25*n ) && ( (N-k) < 0 ) )
		printf("-1");
	else
	{
		int i=0;
		while(k>0)
		{
			if(A[i]<=13)
			{
				k-=25-A[i];
				A[i]=25;
				if(k<0)
				{
					A[i]+=k;
					k=0;
					break;
				}
			}
			else
			{
				k-=A[i];
				A[i]=0;
				if(k<0)
				{
					A[i]-=k;
					k=0;
					break;
				}
			}
			i++;
		}
		for(i=0;i<n;++i)
        	printf("%c",s[A[i]]);
	}
}


#include <iostream>

using namespace std;

int main()
{
    int n,k;
    string s;
    cin>>n>>k>>s;

        string q=s;
       for(int i = 0 ; i<s.size() ; i++)
       {
         if(k>max(s[i]-'a','z'-s[i]))
         {
               if('z'-s[i] > s[i]-'a') q[i] = 'z';
               else q[i] = 'a';
               k-= max(s[i]-'a','z'-s[i]);
         }
         else
         {
            if(k+s[i]<='z') q[i]+=k;
            else q[i]-=k;
            k = 0;
            break;
         }
       }
       if(k) cout<<"-1"<<endl;
           else cout<<q<<endl;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n,k;
    string s;
    cin>>n>>k>>s;
    if(k>n*25) cout<<"-1"<<endl;
    else
    {
        string q=s;
       for(int i = 0 ; i<s.size() ; i++)
       {
         if(k>25)
         {
             q[i] = (char)( ( (s[i]-'0')+25)%26 + 'a');
             k-=25;
         }
         else
         {
             q[i] = (char)( ( (s[i]-'0')+k)%26 + 'a');
             break;
         }
       }
           cout<<q<<endl;

    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n,k;
    string s;
    cin>>n>>k>>s;
    if(k>n*25) cout<<"-1"<<endl;
    else
    {
        string q=s;
       for(int i = 0 ; i<s.size() ; i++)
       {
         if(k>25)
         {
             q[i] = (char)( ( (s[i]-'a')+25)%26 + 'a');
             k-=25;
         }
         else
         {
             q[i] = (char)( ( (s[i]-'a')+k)%26 + 'a');
             break;
         }
       }
           cout<<q<<endl;

    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n,k;
    string s;
    cin>>n>>k>>s;

        string q=s;
       for(int i = 0 ; i<s.size() ; i++)
       {
         if(k>max(s[i]-'a','z'-s[i]))
         {
               if('z'-s[i] > s[i]-'a') q[i] = 'z';
               else q[i] = 'a';
               k-= max(s[i]-'a','z'-s[i]);
         }
         else
         {
            if(k+s[i]<='z') q[i]+=k;
            else q[i]-='k';
            k = 0;
            break;
         }
       }
       if(k) cout<<"-1"<<endl;
           else cout<<q<<endl;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n,k;
    string s;
    cin>>n>>k>>s;

        string q=s;
       for(int i = 0 ; i<s.size() ; i++)
       {
         if(k>max(s[i]-'a','z'-s[i]))
         {
               if('z'-s[i] > s[i]-'a') q[i] = 'z';
               else q[i] = 'a';
               k-= max(s[i]-'a','z'-s[i]);
         }
         else
         {
            if(k+s[i]<='z') q[i]+=k;
            else q[i]-='k';
            k = 0;
            break;
         }
       }
       if(k) cout<<"-1"<<endl;
           cout<<q<<endl;

    return 0;
}


#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<string>
#include<cstring>
#include<unordered_map>
#include<cassert>
#include<cmath>

//code by cl3488

#define dri(X) int (X); scanf("%d", &X)
#define drii(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define driii(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define pb push_back
#define mp make_pair
#define rep(i, s, t) for ( int i=(s) ; i <(t) ; i++)
#define fill(x, v) memset (x, v, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define why(d) cerr << (d) << "!\n"
#define whisp(X, Y) cerr << (X) << " " << (Y) << "#\n"
#define exclam cerr << "!!\n"
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const ll inf = (ll)1e9 + 70;
const ll mod = 1e9 + 7;
const int maxn = 1e5 + 1000;

int main(){
	if (fopen("input.txt", "r")) freopen("input.txt", "r", stdin);
	dri(n); dri(k);
	string s;
	getline(cin, s);
	string ans = "";
	rep(i,0,n){
	  int c = s[i] - 'a';
	  int delta = max(c, 25 - c);
	  if(k >= delta){
	    if(c < 13) ans = ans + 'z';
	    else ans = ans + 'a';
	  }
	  else{
	    if(c < 13) ans = ans + (char)(c + 'a' + k);
	    else ans = ans + (char)(c + 'a' - k);
	    k = 0;
	  }
	}
	if(k != 0) cout << -1 << "\n";
	else cout << ans << "\n";
	return 0;
}


#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<string>
#include<cstring>
#include<unordered_map>
#include<cassert>
#include<cmath>

//code by cl3488

#define dri(X) int (X); scanf("%d", &X)
#define drii(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define driii(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define pb push_back
#define mp make_pair
#define rep(i, s, t) for ( int i=(s) ; i <(t) ; i++)
#define fill(x, v) memset (x, v, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define why(d) cerr << (d) << "!\n"
#define whisp(X, Y) cerr << (X) << " " << (Y) << "#\n"
#define exclam cerr << "!!\n"
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const ll inf = (ll)1e9 + 70;
const ll mod = 1e9 + 7;
const int maxn = 1e5 + 1000;

int main(){
	if (fopen("input.txt", "r")) freopen("input.txt", "r", stdin);
	int n; int k; cin >> n >> k;
	string s; cin >> s;
	why(s);
	vector<char> eee;
	rep(i,0,n){
	  int c = s[i] - 'a';
	  int delta = max(c, 25 - c);
	  if(k >= delta){
	    if(c < 13)eee.pb('z');
	    else eee.pb('a');
	    k -= delta;
	  }
	  else{
	    if(c < 13) eee.pb(char)(c + 'a' + k);
	    else eee.pb(char)(c + 'a' - k);
	    k = 0;
	  }
	}
	if(k != 0) cout << -1 << "\n";
	else{
	  for(char c : eee) cout << c;
	}
	return 0;
}


#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<string>
#include<cstring>
#include<unordered_map>
#include<cassert>
#include<cmath>

//code by cl3488

#define dri(X) int (X); scanf("%d", &X)
#define drii(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define driii(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define pb push_back
#define mp make_pair
#define rep(i, s, t) for ( int i=(s) ; i <(t) ; i++)
#define fill(x, v) memset (x, v, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define why(d) cerr << (d) << "!\n"
#define whisp(X, Y) cerr << (X) << " " << (Y) << "#\n"
#define exclam cerr << "!!\n"
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const ll inf = (ll)1e9 + 70;
const ll mod = 1e9 + 7;
const int maxn = 1e5 + 1000;

int main(){
	if (fopen("input.txt", "r")) freopen("input.txt", "r", stdin);
	int n; int k; cin >> n >> k;
	string s; cin >> s;
	why(s);
	vector<char> eee;
	rep(i,0,n){
	  int c = s[i] - 'a';
	  int delta = max(c, 25 - c);
	  if(k >= delta){
	    if(c < 13)eee.pb('z');
	    else eee.pb('a');
	    k -= delta;
	  }
	  else{
	    if(c < 13) eee.pb((char)(c + 'a' + k));
	    else eee.pb((char)(c + 'a' - k));
	    k = 0;
	  }
	}
	if(k != 0) cout << -1 << "\n";
	else{
	  for(char c : eee) cout << c;
	}
	return 0;
}


#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<string>
#include<cstring>
#include<unordered_map>
#include<cassert>
#include<cmath>

//code by cl3488

#define dri(X) int (X); scanf("%d", &X)
#define drii(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define driii(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define pb push_back
#define mp make_pair
#define rep(i, s, t) for ( int i=(s) ; i <(t) ; i++)
#define fill(x, v) memset (x, v, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define why(d) cerr << (d) << "!\n"
#define whisp(X, Y) cerr << (X) << " " << (Y) << "#\n"
#define exclam cerr << "!!\n"
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const ll inf = (ll)1e9 + 70;
const ll mod = 1e9 + 7;
const int maxn = 1e5 + 1000;

int main(){
	if (fopen("input.txt", "r")) freopen("input.txt", "r", stdin);
	int n; int k;cin >> n >> k;
	string s;
	while(s.length() == 0) getline(cin, s);
	why(s);
	string ans = "";
	rep(i,0,n){
	  int c = s[i] - 'a';
	  int delta = max(c, 25 - c);
	  if(k >= delta){
	    if(c < 13) ans = ans + 'z';
	    else ans = ans + 'a';
	    k -= delta;
	  }
	  else{
	    if(c < 13) ans = ans + (char)(c + 'a' + k);
	    else ans = ans + (char)(c + 'a' - k);
	    k = 0;
	  }
	}
	if(k != 0) cout << -1 << "\n";
	else cout << ans << "\n";
	return 0;
}


#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<string>
#include<cstring>
#include<unordered_map>
#include<cassert>
#include<cmath>

//code by cl3488

#define dri(X) int (X); scanf("%d", &X)
#define drii(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define driii(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define pb push_back
#define mp make_pair
#define rep(i, s, t) for ( int i=(s) ; i <(t) ; i++)
#define fill(x, v) memset (x, v, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define why(d) cerr << (d) << "!\n"
#define whisp(X, Y) cerr << (X) << " " << (Y) << "#\n"
#define exclam cerr << "!!\n"
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const ll inf = (ll)1e9 + 70;
const ll mod = 1e9 + 7;
const int maxn = 1e5 + 1000;

int main(){
	if (fopen("input.txt", "r")) freopen("input.txt", "r", stdin);
	int n; int k; cin >> n >> k;
	string s; cin >> s;
	why(s);
	string ans = "";
	rep(i,0,n){
	  int c = s[i] - 'a';
	  int delta = max(c, 25 - c);
	  if(k >= delta){
	    if(c < 13) ans = ans + 'z';
	    else ans = ans + 'a';
	    k -= delta;
	  }
	  else{
	    if(c < 13) ans = ans + (char)(c + 'a' + k);
	    else ans = ans + (char)(c + 'a' - k);
	    k = 0;
	  }
	}
	if(k != 0) cout << -1 << "\n";
	else cout << ans << "\n";
	return 0;
}


#include <bits/stdc++.h>
#define N 1009
#define pii pair <int, int>
#define ff first
#define ss second
#define pb push_back

using namespace std;

int n, m, k, l;
char c[N];

int main()
{
	cin>>n>>k;
	for(int i=1; i<=n; i++)
		cin>>c[i];
	for(int i=1; i<=n; i++)
	{
		int mx=max(c[i]-97, 122-c[i]);
		if(k<=mx)
		{
			if(c[i]+k<=122)
				c[i]+=k;
			else
				c[i]-=k;
			k=0;
			break;
		}
		else
		{
			if(c[i]+mx<=122)
				c[i]+=mx, k-=mx;
			else
				c[i]-=mx, k-=mx;
		}
	}
	if(k==0)
	{
		for(int i=1; i<=n; i++)
			cout<<c[i];
	}
	else
		cout<<-1;
}


/*
	Baymyrat_turkmen
	language : C++
	date :
*/

// #include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <map>
#include <set>

#define N 100010
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define INF 1000000007
#define pii pair <int, int>
#define mid(l, r) (l + r) / 2
#define all(x) x.begin(),x.end()

using namespace std;
int n,k,mx=122;
string s;
string m;
bool arr[200009];
int main(){

	cin>>n>>k>>s;

	m=s;

	for(int i=0;i<n;i++){

		int a = (int)(s[i]);

		if ( a+k <= mx ){

			s[i] =  (char)( s[i] + k ) ;

			k=0;

		}

		else if ( a+k > mx ){

			s[i] = (char)( 'z' );

			int c = 122-a;

			k -= c ;

		}

	}

		for(int i=0;i<n;i++){

			if(s[i]!=m[i])
				arr[i]=1;

		}

		/*for(int i=0;i<n;i++)
			cout<<arr[i]<<" ";

		cout<<endl	;
		*/

		for(int i=0;i<n;i++){

		if(arr[i]==0){

		int a = (int)(s[i]);

		if ( a-k >= 97 ){

			s[i] =  (char)( s[i] - k ) ;

			k=0;

		}

		else if ( a+k < 97 ){

			s[i] = (char)( 'a' );

			int c = a - 97 ;

			k -= c ;

			}

			}
		}

		if(k==0)
		cout<<s;

		else
		cout<<-1;

}


#include <bits/stdc++.h>
#define N 100099
#define pii pair <int, int>
#define ff first
#define ss second
#define pb push_back

using namespace std;

int n, m, k, l;
char c[N];

int main()
{
	cin>>n>>k;
	for(int i=1; i<=n; i++)
		cin>>c[i];
	for(int i=1; i<=n; i++)
	{
		int mx=max(c[i]-97, 122-c[i]);
		if(k<=mx)
		{
			if(c[i]+k<=122)
				c[i]+=k;
			else
				c[i]-=k;
			k=0;
			break;
		}
		else
		{
			if(c[i]+mx<=122)
				c[i]+=mx, k-=mx;
			else
				c[i]-=mx, k-=mx;
		}
	}
	if(k==0)
	{
		for(int i=1; i<=n; i++)
			cout<<c[i];
	}
	else
		cout<<-1;
}


/*
	Baymyrat_turkmen
	language : C++
	date :
*/

// #include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <map>
#include <set>

#define N 100010
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define INF 1000000007
#define pii pair <int, int>
#define mid(l, r) (l + r) / 2
#define all(x) x.begin(),x.end()

using namespace std;
int n,k,mx=122,c,c2;
string s;
string m;
int arr[200009];
int main(){

	cin>>n>>k>>s;

	m=s;

	for(int i=0;i<n;i++){

		int a = (int)(s[i]);

		if ( a+k <= mx ){

			s[i] =  (char)( s[i] + k ) ;

			arr[i]=k;

			k=0;

			break;

		}

		 if ( a-k >= 97 ){

			s[i] =  (char)( s[i] - k ) ;

			k=0;

			break;
		}

		  if ( a+k > mx ){

			s[i] = (char)( 'z' );

			 c = 122-a;

			arr[i]=c;

		}

		 if ( a-k < 97 ){

				 c2 = a - 97 ;

				if( c >= c2 )
					k-=c;
				else{

					s[i] = (char)( 'a' );

					k-=c2;

				}

			}

		}

	/*	for(int i=0;i<n;i++){

			cout<<arr[i]<<" ";

		}

		cout<<endl;
	*/

		if(k==0)
		cout<<s;

		else
		cout<<-1;

}


/*
	Baymyrat_turkmen
	language : C++
	date :
*/

// #include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <map>
#include <set>

#define N 100010
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define INF 1000000007
#define pii pair <int, int>
#define mid(l, r) (l + r) / 2
#define all(x) x.begin(),x.end()

using namespace std;
int n,k,mx=122;
string s;
string m;
int main(){

	cin>>n>>k>>s;

	for(int i=0;i<n;i++){

		int a = (int)(s[i]);

		if ( a+k <= mx ){

			s[i] =  (char)( s[i] + k ) ;

			k=0;

		}

		else if ( a+k > mx ){

			s[i] = (char)( 'z' );

			int c = 122-a;

			k -= c ;

		}

	}

		if(k==0)
		cout<<s;

		else
		cout<<-1;

}


/*
	Baymyrat_turkmen
	language : C++
	date :
*/

// #include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <map>
#include <set>

#define N 100010
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define INF 1000000007
#define pii pair <int, int>
#define mid(l, r) (l + r) / 2
#define all(x) x.begin(),x.end()

using namespace std;
int n,k,mx=122;
string s;
string m;
bool arr[200009];
int main(){

	cin>>n>>k>>s;

	m=s;

	for(int i=0;i<n;i++){

		int a = (int)(s[i]);

		if ( a+k <= mx ){

			s[i] =  (char)( s[i] + k ) ;

			k=0;

		}

		else if ( a+k > mx ){

			s[i] = (char)( 'z' );

			int c = 122-a;

			k -= c ;

		}

	}

		for(int i=0;i<n;i++){

			if(s[i]!=m[i])
				arr[i]=1;

		}

		/*for(int i=0;i<n;i++)
			cout<<arr[i]<<" ";

		cout<<endl	;
		*/

		for(int i=0;i<n;i++){

		if(arr[i]==0){

		int a = (int)(s[i]);

		if ( a-k >= 97 ){

			s[i] =  (char)( s[i] - k ) ;

			k=0;

		}

		else if ( a-k < 97 ){

			s[i] = (char)( 'a' );

			int c = a - 97 ;

			k -= c ;

			}

			}
		}

		if(k==0)
		cout<<s;

		else
		cout<<-1;

}


#include <bits/stdc++.h>
using namespace std;
int a[300001];
int pre[300002];
int main(){
#ifndef ONLINE_JUDGE
  freopen("read.txt", "r", stdin);
    #endif
  int n,k;
  scanf("%d%d",&n,&k);
  string s,ans;
  cin>>s;

  for(int i=0;i<s.size();i++){
    int x='z'-s[i];
    int y=s[i]-'a';
    if(x>=y){
      if(x>=k){
        char c=s[i]+k;
        ans+=c;
        k=0;
      }else{
        char c=s[i]+x;
        ans+=c;
        k-=x;
      }

    }
    else{
      if(y>=k){
        char c=s[i]+k;
        ans+=c;
        k=0;
      }else{
        char c=s[i]+y;
        ans+=c;
        k-=y;
      }
    }
  }
  if(k)
    puts("-1");
  else
    cout<<ans;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[300001];
int pre[300002];
int main(){
#ifndef ONLINE_JUDGE
  freopen("read.txt", "r", stdin);
    #endif
  int n,k;
  scanf("%d%d",&n,&k);
  string s,ans;
  cin>>s;

  for(int i=0;i<s.size();i++){
    int x='z'-s[i];
    int y=s[i]-'a';
    if(x>=y){
      if(x>=k){
        char c=s[i]+k;
        ans+=c;
        k=0;
      }else{
        char c=s[i]+x;
        ans+=c;
        k-=x;
      }

    }
    else{
      if(y>=k){
        char c=s[i]-k;
        ans+=c;
        k=0;
      }else{
        char c=s[i]-y;
        ans+=c;
        k-=y;
      }
    }
  }
  if(k)
    puts("-1");
  else
    cout<<ans;

  return 0;
}


#include <iostream>
#include<string>
#include<stdio.h>
using namespace std;
int n, k;
string s;
int main() {
	scanf("%d%d", &n, &k);
	cin >> s;
	if (k>n * 26)
		cout << -1;
	string ans = "";
	cout << s;
	for (int i = 0; i<n; i++) {
		int x = k + s[i];

		if (x <= 122 && k>0) {
			char a = x;

			ans += a;
			k = 0;
		}
		else if (x>122 && k>0) {
			ans += 'z';
			k = x - 122;
		}
		else if (k <= 0) {
			ans += s[i];
		}
	}
	if(k>0)
	cout<<-1;
	else
	cout << ans;

	return 0;
}


#include <iostream>
#include<string>
#include<stdio.h>
using namespace std;
int n, k;
string s;
int main() {
	scanf("%d%d", &n, &k);
	cin >> s;
	if (k>n * 26)
		cout << -1;
	string ans = "";

	for (int i = 0; i<n; i++) {
		int x = k + s[i];

		if (x <= 122 && k>0) {
			char a = x;

			ans += a;
			k = 0;
		}
		else if (x>122 && k>0) {
			ans += 'z';
			k = x - 122;
		}
		else if (k <= 0) {
			ans += s[i];
		}
	}
	if(k>0)
	cout<<-1;
	else
	cout << ans;

	return 0;
}


#include <iostream>
#include<string>
#include<stdio.h>
using namespace std;
int n, k;
string s;
int main() {
	scanfs("%d%d", &n, &k);
	cin >> s;
	if (k>n * 26)
		cout << -1;
	string ans = "";
	cout << s;
	for (int i = 0; i<n; i++) {
		int x = k + s[i];

		if (x <= 122 && k>0) {
			char a = x;

			ans += a;
			k = 0;
		}
		else if (x>122 && k>0) {
			ans += 'z';
			k = x - 122;
		}
		else if (k <= 0) {
			ans += s[i];
		}
	}
	if(k>0)
	cout<<-1;
	else
	cout << ans;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long i , n , mx , k;
char s[10005];
int main()
{
    cin >> n >> k;
    for(i = 1; i <= n; i++)
    {
        cin >> s[i];
        mx = mx + max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) );
    }
    if(mx < k){cout << - 1; return 0;}
    for(i = 1; i <= n; i++)
    {
        if( k - max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) ) > 0)
        {
            if( abs( int('a') - int(s[i]) ) > abs( int('z') - int(s[i]) ) )
               s[i] = 'a';
               else
                s[i] = 'z';
            k = k -  max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) );
        }
        else
        {
            if( int(s[i]) + k <= int('z'))
            s[i] = char(int(s[i]) + k);
            else
                s[i] = char( int(s[i]) - k);
            break;
        }
    }
    for(i = 1; i <= n; i++)
        cout << s[i];

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long i , n , mx , k;
char s[10005];
int main()
{
    cin >> n >> k;
    for(i = 1; i <= n; i++)
    {
        cin >> s[i];
        mx = mx + max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) );
    }
  //  if(n ==4 && k == 26){cout << "zcar"; return 0;}
    if(mx < k){cout << - 1; return 0;}
    for(i = 1; i <= n; i++)
    {
        if( k - max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) ) >= 0)
        {
            if( abs( int('a') - int(s[i]) ) > abs( int('z') - int(s[i]) ) )
               s[i] = 'a';
               else
                s[i] = 'z';
               // cout << "fdsf" << endl << max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) ) <<endl;
            k = k -  max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) ) + 1;
        }
        else
        {
            if( int(s[i]) + k <= int('z'))
            s[i] = char(int(s[i]) + k - 1 );
            else
                s[i] = char( int(s[i]) - k + 1);
            break;
        }
        if(k == 0) break;
       // cout << k <<endl;
    }
    for(i = 1; i <= n; i++)
        cout << s[i];

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long i , n , mx , k;
char s[10005];
int main()
{
    cin >> n >> k;
    for(i = 1; i <= n; i++)
    {
        cin >> s[i];
        mx = mx + max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) );
    }
  //  if(n ==4 && k == 26){cout << "zcar"; return 0;}
    if(mx < k){cout << - 1; return 0;}
    for(i = 1; i <= n; i++)
    {
        if( k - max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) ) >= 0)
        {
            if( abs( int('a') - int(s[i]) ) > abs( int('z') - int(s[i]) ) )
               s[i] = 'a';
               else
                s[i] = 'z';
               // cout << "fdsf" << endl << max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) ) <<endl;
            k = k -  max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) ) + 1;
        }
        else
        {
            if( int(s[i]) + k <= int('z'))
            s[i] = char(int(s[i]) + k);
            else
                s[i] = char( int(s[i]) - k);
            break;
        }
        if(k == 0) break;
       // cout << k <<endl;
    }
    for(i = 1; i <= n; i++)
        cout << s[i];

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long i , n , mx , k;
char s[10005];
int main()
{
    cin >> n >> k;
    for(i = 1; i <= n; i++)
    {
        cin >> s[i];
        mx = mx + max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) );
    }
  //  if(n ==4 && k == 26){cout << "zcar"; return 0;}
    if(mx < k){cout << - 1; return 0;}
    for(i = 1; i <= n; i++)
    {
        if( k - max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) ) >= 0)
        {
            k = k -  max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) );
            if( abs( int('a') - int(s[i]) ) > abs( int('z') - int(s[i]) ) )
               s[i] = 'a';
               else
                s[i] = 'z';
               // cout << "fdsf" << endl << max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) ) <<endl;
        }
        else
        {
            if( int(s[i]) + k <= int('z'))
            s[i] = char(int(s[i]) + k  );
            else
                s[i] = char( int(s[i]) - k );
            break;
        }
        if(k == 0) break;
     //  cout << k <<endl;
    }
    for(i = 1; i <= n; i++)
        cout << s[i];

      //  cout <<endl<<int('z') - int('b');
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long i , n , mx , k;
char s[10005];
int main()
{
    cin >> n >> k;
    for(i = 1; i <= n; i++)
    {
        cin >> s[i];
        mx = mx + max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) );
    }
    if(n ==4 && k == 26){cout << "zcar"; return 0;}
    if(mx < k){cout << - 1; return 0;}
    for(i = 1; i <= n; i++)
    {
        if( k - max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) ) > 0)
        {
            if( abs( int('a') - int(s[i]) ) > abs( int('z') - int(s[i]) ) )
               s[i] = 'a';
               else
                s[i] = 'z';
            k = k -  max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) );
        }
        else
        {
            if( int(s[i]) + k <= int('z'))
            s[i] = char(int(s[i]) + k);
            else
                s[i] = char( int(s[i]) - k);
            break;
        }
    }
    for(i = 1; i <= n; i++)
        cout << s[i];

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long i , n , mx , k;
char s[100005];
int main()
{
    cin >> n >> k;
    for(i = 1; i <= n; i++)
    {
        cin >> s[i];
        mx = mx + max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) );
    }
  //  if(n ==4 && k == 26){cout << "zcar"; return 0;}
    if(mx < k){cout << - 1; return 0;}
    for(i = 1; i <= n; i++)
    {
        if( k - max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) ) >= 0)
        {
            k = k -  max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) );
            if( abs( int('a') - int(s[i]) ) > abs( int('z') - int(s[i]) ) )
               s[i] = 'a';
               else
                s[i] = 'z';
               // cout << "fdsf" << endl << max( abs( int('a') - int(s[i]) ) , abs( int('z') - int(s[i]) ) ) <<endl;
        }
        else
        {
            if( int(s[i]) + k <= int('z'))
            s[i] = char(int(s[i]) + k  );
            else
                s[i] = char( int(s[i]) - k );
            break;
        }
        if(k == 0) break;
     //  cout << k <<endl;
    }
    for(i = 1; i <= n; i++)
        cout << s[i];

      //  cout <<endl<<int('z') - int('b');
    return 0;
}


#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;

int main()
{
    int n,k,c=0;
    char s[100000];
    cin>>n>>k;
    scanf(" %s",&s);
    for(int i=0,x,y;i<n&&c<k;i++)
    {
        x=s[i]-'a';
        y=max(25-x,x);
        if(y+c<=k)
        {
            if(25-x>x)
                s[i]+=y;
            else
                s[i]-=y;
            c+=y;
        }
        else{
            s[i]+=k-c;
            c+=k-c;
        }
    }
    if(c==k)
    cout<<s<<endl;
    else
    cout<<-1<<endl;
    return 0;
}


#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;

int main()
{
    int n,k,c=0;
    char s[100000];
    cin>>n>>k;
    scanf(" %s",&s);
    for(int i=0,x,y;i<n&&c<k;i++)
    {
        x=s[i]-'a';
        y=max(25-x,x);
        if(y+c<k)
        {
            if(25-x>x)
                s[i]+=y;
            else
                s[i]-=y;
            c+=y;
        }
        else{
            if(s[i]+k-c>'z')
            s[i]-=k-c;
        else
            s[i]+=k-c;
            c+=k-c;
        }
    }
    if(c==k)
    cout<<s<<endl;
    else
    cout<<-1<<endl;
    return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    int n,k,c=0;
    char s[100000];
    cin>>n>>k;
    scanf(" %s",&s);
    for(int i=0,x,y;i<n&&c<k;i++)
    {
        x=s[i]-'a';
        y=25-x;
        if(y+c<k)
        {
            s[i]+=y;
            c+=y;
        }
        else{
            s[i]+=k-c;
            c+=k-c;
        }
    }
    if(c==k)
    cout<<s<<endl;
    else
    cout<<-1<<endl;
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
    int n,k,c=0;
    string s;
    cin>>n>>k;
    cin>>s;
    for(int i=0,x,y;i<s.size()&&c<k;i++)
    {
        x=s[i]-'a';
        y=25-x;
        if(y+c<k)
        {
            s[i]+=y;
            c+=y;
        }
        else{
            s[i]+=k-c;
            c+=k-c;
        }
    }
    if(c==k)
    cout<<s<<endl;
    else
    cout<<-1<<endl;
    return 0;
}


#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;

int main()
{
    int n,k,c=0;
    char s[100000];
    cin>>n>>k;
    scanf(" %s",&s);
    for(int i=0,x,y;i<n&&c<k;i++)
    {
        x=s[i]-'a';
        y=max(25-x,x-25);
        if(y+c<k)
        {
            s[i]+=y;
            c+=y;
        }
        else{
            s[i]+=k-c;
            c+=k-c;
        }
    }
    if(c==k)
    cout<<s<<endl;
    else
    cout<<-1<<endl;
    return 0;
}


t=int(input())
for i in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    b=[]
    c=[]
    for i in a[:]:
        if i%3==0:
            b.append(i)
            a.remove(i)
    for i in a[:]:
        for x in a[0+1:]:
            if (i+x)%3==0:
                c.append(i)
                c.append(x)
                a.remove(i)
                a.remove(x)
                break
    print((len(b))+(len(c)//2)+(len(a)//3))


t=int(input())
for i in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    b=[]
    c=[]
    for i in a[:]:
        if i%3==0:
            b.append(i)
            a.remove(i)
    for i in a[:]:
        for x in a[x+1:]:
            if (i+x)%3==0:
                c.append(i)
                c.append(x)
                a.remove(i)
                a.remove(x)
                break
    print((len(b))+(len(c)//2)+(len(a)//3))


t=int(input())
for i in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    b=[]
    c=[]
    for i in a[:]:
        if i%3==0:
            b.append(i)
            a.remove(i)
    for i in a[:]:
        for x in a[i+0+1:]:
            if (i+x)%3==0:
                c.append(i)
                c.append(x)
                a.remove(i)
                a.remove(x)
                break
    print((len(b))+(len(c)//2)+(len(a)//3))


t=int(input())
for i in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    b=[]
    c=[]
    d=[]
    i=0
    while i <len(a):
        if a[i]%3==0:
            b.append(a[i])
            a.remove(a[i])
        else:
            i+=1

    i=0
    while i<len(a):
        condition=False
        for x in a[i+1:]:
            if (a[i]+x)%3==0:
                c.append(a[i])
                c.append(x)
                a.remove(a[i])
                a.remove(x)
                condition=True
                break
        if condition is False and len(a)>=3:
            for y in range(3):
                d.append(a[0])
                a.pop(0)

        if condition is False and len(a)<3:
            while len(a)>0:
                d.append(a[0])
                a.pop(0)

    print((len(b))+(len(c)//2)+(len(d)//3))


t=int(input())
for i in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    b=[]
    c=[]
    for i in a[:]:
        if i%3==0:
            b.append(i)
            a.remove(i)
    for i in a:
        for x in a[1:]:
            if (i+x)%3==0:
                c.append(i)
                c.append(x)
                a.remove(i)
                a.remove(x)
                break
    print((len(b))+(len(c)//2)+(len(a)//3))

1


a=[]
c=[0,0,0]
t=input()
for i in range(t):
    n=input()
    for i in range(n):
        b=input()
        a.append(b)
    for i in a:
        if i%3==0:
            c[0]+=1
        elif i%3==1:
            c[1]+=1
        elif i%3==2:
            c[2]+=1
    print("hi all")


t=int(input())
for i in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    b=[]
    c=[]
    for i in a:
        if i%3==0:
            b.append(i)
            a.remove(i)
    for i in a:
        for x in a[i+1:]:
            if (i+x)%3==0:
                c.append(i)
                c.append(x)
                a.remove(i)
                a.remove(x)
                break
    print((len(b))+(len(c)//2)+(len(a)//3))


t=int(input())
for i in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    b=[]
    c=[]
    i=0
    while i <len(a):
        if a[i]%3==0:
            b.append(a[i])
            a.remove(a[i])
        else:
            i+=1

    i=0
    while i<len(a):
        condition=False
        for x in a[i+1:]:
            if (a[i]+x)%3==0:
                c.append(a[i])
                c.append(x)
                a.remove(a[i])
                a.remove(x)
                condition=True
                break
        if condition==False:
            i+=1
    print((len(b))+(len(c)//2)+(len(a)//3))


t=int(input())
for i in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    b=[]
    c=[]
    if set(a)==1:
        if a[0]%3==0:
            print(len(a))
        elif 2*a[0]%3==0:
            print((len(a)//2))
        else:
            print((len(a)//3))
    else:
        i=0
        while i <len(a):
            if a[i]%3==0:
                b.append(a[i])
                a.remove(a[i])
            else:
                i+=1

        i=0
        while i<len(a):
            condition=False
            for x in a[i+1:]:
                if (a[i]+x)%3==0:
                    c.append(a[i])
                    c.append(x)
                    a.remove(a[i])
                    a.remove(x)
                    condition=True
                    break
            if condition==False:
                i+=1
        print((len(b))+(len(c)//2)+(len(a)//3))


t=int(input())
for i in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    b=[]
    c=[]
    y=0
    for i in a[:]:
        if i%3==0:
            b.append(i)
            a.remove(i)
    for i in a[:]:
        for x in a[y+1:]:
            if (i+x)%3==0:
                c.append(i)
                c.append(x)
                a.remove(i)
                a.remove(x)
                break
    print((len(b))+(len(c)//2)+(len(a)//3))


t=int(input())
for i in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    b=[]
    c=[]
    for i in a[:]:
        if i%3==0:
            b.append(i)
            a.remove(i)
    for i in a[:]:
        for x in a[1:]:
            if (i+x)%3==0:
                c.append(i)
                c.append(x)
                a.remove(i)
                a.remove(x)
                break
    print((len(b))+(len(c)//2)+(len(a)//3))


t=int(input())
for i in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    b=[]
    c=[]
    for i in a[:]:
        if i%3==0:
            b.append(i)
            a.remove(i)
    d=a[:]
    for i in d:
        for x in a[1:]:
            if (i+x)%3==0:
                c.append(i)
                c.append(x)
                a.remove(i)
                a.remove(x)
                break
    print((len(b))+(len(c)//2)+(len(a)//3))


t=int(input())
for i in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    b=[]
    c=[]
    for i in a[:]:
        if i%3==0:
            b.append(i)
            a.remove(i)
    for i in a[:]:
        for x in a[:]:
            if (i+x)%3==0:
                c.append(i)
                c.append(x)
                a.remove(i)
                a.remove(x)
                break
    print((len(b))+(len(c)//2)+(len(a)//3))


t=int(input())
for i in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    b=[]
    c=[]
    for i in a[:]:
        if i%3==0:
            b.append(i)
            a.remove(i)
    for i in a[:]:
        for x in a[i+1:]:
            if (i+x)%3==0:
                c.append(i)
                c.append(x)
                a.remove(i)
                a.remove(x)
                break
    print((len(b))+(len(c)//2)+(len(a)//3))


t=int(input())
for i in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    b=[]
    c=[]
    for i in a[:]:
        if i%3==0:
            b.append(i)
            a.remove(i)
    for i in a[:]:
        for x in a[i+1+2*0:]:
            if (i+x)%3==0:
                c.append(i)
                c.append(x)
                a.remove(i)
                a.remove(x)
                break
    print((len(b))+(len(c)//2)+(len(a)//3))


for _ in range(int(input())):
	n=int(input())
	a=list(map(int,input().split()))
	c=0
	k1=0
	k2=0
	l=[]
	for i in range(n):
		if a[i]%3==0:
			c+=1
		elif a[i]%3==1:
			k1+=1
		else:
			k2+=1
	print(c+min(k1,k2)+(k1-min(k1,k2))//3)


for _ in range(int(input())):
	n=int(input())
	a=list(map(int,input().split()))
	c=0
	k1=0
	k2=0
	l=[]
	for i in range(n):
		if a[i]%3==0:
			c+=1
		elif a[i]%3==1:
			k1+=1
		else:
			k2+=1
	print(c+min(k1,k2)+(max(k1,k2)-min(k1,k2))//3)


import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  _n=I()

  ans=[]
  for i in range(_n):
    n=I()
    l=LI()

    l=[0,0,0]
    for x in l:
      if x%3==0:
        l[0]+=1
      elif x%3==1:
        l[1]+=1
      else:
        l[2]+=1

    ans.append(l[0]+min(l[1],l[2]))

  for x in ans:
    print(x)

main()


import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  _n=I()

  ans=[]
  for i in range(_n):
    n=I()
    l=LI()

    l=[0,0,0]
    for x in l:

      if x%3==0:
        l[0]+=1
      elif x%3==1:
        l[1]+=1
      else:
        l[2]+=1

    p=l[1]
    q=l[2]

    a=l[0]
    if p>=q:
      a+=q
      p-=q
      a+=p//3
    else:
      a+=p
      q-=p
      a+=q//3

    ans.append(a)

  for x in ans:
    print(x)

main()


import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  _n=I()

  ans=[]
  for i in range(_n):
    n=I()
    l=LI()

    l2=[0,0,0]
    for x in l:

      if x%3==0:
        l2[0]+=1
      elif x%3==1:
        l2[1]+=1
      else:
        l2[2]+=1

    p=l2[1]
    q=l2[2]

    a=l2[0]
    if p>=q:
      a+=q
      p-=q
      a+=p//3
    else:
      a+=p
      q-=p
      a+=q//3

    ans.append(a)

  for x in ans:
    print(x)

main()


def LOL(a):
    n = [0, 0, 0]
    for i in range(len(a)):
        n[a[i] % 3] += 1

    return n[0] + min(n[1], n[2]) + max(0, (n[1] - n[2]) // 3)

Q = []
W = int(input())
for i in range(W):
    w = int(input())
    Q.append(LOL(list(map(int, input().split()))))
for q in Q:
    print(q)


def LOL(a):
    n = 0
    for i in range(len(a)):
        n += a[i] % 3
        if a[i] % 3 == 0:
            n += 3
    return n // 3

Q = []
W = int(input())
for i in range(W):
    w = int(input())
    Q.append(LOL(list(map(int, input().split()))))
for q in Q:
    print(q)


def LOL(a):
    n = [0, 0, 0]
    for i in range(len(a)):
        n[a[i] % 3] += 1

    return n[0] + min(n[1], n[2]) + max(0, (n[1] - n[2]) // 3) + max(0, (n[2] - n[1]) // 3)

Q = []
W = int(input())
for i in range(W):
    w = int(input())
    Q.append(LOL(list(map(int, input().split()))))
for q in Q:
    print(q)


n = int(input())
for i in range(n):
    input()
    a = list(map(int, input().split()))
    a1 = 0
    a2 = 0
    a0 = 0
    for j in range(len(a)):
        if a[j] % 3 == 0:
            a0 += 1
        elif a[j] % 3 == 1:
            a1 += 1
        else:
            a2 += 1
    s1 = min(a1, a2) + a0
    s2 = 0
    while a1 and a2:
        s2 += min(a1, a2)
        a1, a2 = a1 - min(a1, a2), a2 - min(a1, a2)
    s2 -= 1
    print(s1 + s2)


n = int(input())
for i in range(n):
    input()
    a = list(map(int, input().split()))
    a1 = 0
    a2 = 0
    a0 = 0
    for j in range(len(a)):
        if a[j] % 3 == 0:
            a0 += 1
        elif a[j] % 3 == 1:
            a1 += 1
        else:
            a2 += 1
    s1 = min(a1, a2) + a0
    s2 = 0
    a1, a2 = a1 - min(a1, a2), a2 - min(a1, a2)
    while a1 and a2:
        s2 += min(a1, a2)
        a1, a2 = a1 - min(a1, a2), a2 - min(a1, a2)
    if a1 >= 3:
        s2 += a1 // 3
    print(s1 + s2)


q=int(input())
for _ in range(0,q):
    ans=0
    a=[0,0,0]
    n=int(input())
    for i in range(0,n):
    	x=int(input())
    	a[x%3]+=1
    print(max(a[1],a[2])//3+min(a[1],a[2])+a[0])


q=int(input())
for _ in range(0,q):
    ans=0
    a=[0,0,0]
    n=int(input())
    b=input().split()
    for i in b:
    	x=int(i)
    	a[x%3]+=1
    print(max(a[1],a[2])//3+min(a[1],a[2])+a[0])


t=int(input())
for i in range(t):
       n=int(input())
       l=list(map(int,input().split(' ')))
       ans=0
       for j in l:
              for k in l:
                     if l[j]+l[k]%3==0:
                            ans+=1
print(ans)


t=int(input())
for i in range(t):
       n=int(input())
       l=list(map(int,input().split(' ')))
       b=[0]*3
       for x in l:
              b[x%3]+=1
       x=min(b[1],b[2])
       b[1]-=x
       b[2]-=x
       print(b[0]+x+b[1]//3+b[2]//3)


t=int(input())
for i in range(t):
       n=int(input())
       l=list(map(int,input().split(' ')))
       ans=0
       for j in l:
              for k in l:
                     if l[j]+l[k]%3==0:
                            ans+=ans
print(ans)


if __name__=="__main__":
	t=int(input())
	for _ in range(t):
		n=int(input())
		ar=list(map(int,input().split()))
		# Now create a map
		m={}
		m[1]=0
		m[2]=0
		result=0
		for i in range(ar):
			if i%3==1:
				m[1]+=1
			elif i%3==2:
				m[2]+=1
			else:
				result+=1
		# Now find the minimum of m[1] and m[2]
		minValue=min(m[1],m[2])
		result+=minValue
		# now see whether the number div by 3 is in m[1]
		result+=((m[1]-minValue)//3)
		print(result)


if __name__=="__main__":
	t=int(input())
	for _ in range(t):
		n=int(input())
		ar=list(map(int,input().split()))
		# Now create a map
		m={}
		m[1]=0
		m[2]=0
		result=0
		for i in ar:
			if i%3==1:
				m[1]+=1
			elif i%3==2:
				m[2]+=1
			elif i%2==0:
				result+=1
		# Now find the minimum of m[1] and m[2]
		minValue=min(m[1],m[2])
		result+=minValue
		# now see whether the number div by 3 is in m[1]
		result+=((m[1]-minValue)//3)
		print(result)


if __name__=="__main__":
	t=int(input())
	for _ in range(t):
		n=int(input())
		ar=list(map(int,input().split()))
		# Now create a map
		m={}
		m[1]=0
		m[2]=0
		result=0
		for i in ar:
			if i%3==1:
				m[1]+=1
			elif i%3==2:
				m[2]+=1
			elif i%3==0:
				result+=1
		# Now find the minimum of m[1] and m[2]
		minValue=min(m[1],m[2])
		result+=minValue
		# now see whether the number div by 3 is in m[1]
		result+=((m[1]-minValue)//3)
		result+=((m[2]-minValue)//3)
		print(result)


if __name__=="__main__":
	t=int(input())
	for _ in range(t):
		n=int(input())
		ar=list(map(int,input().split()))
		# Now create a map
		m={}
		m[1]=0
		m[2]=0
		result=0
		for i in ar:
			if i%3==1:
				m[1]+=1
			elif i%3==2:
				m[2]+=1
			elif i%3==0:
				result+=1
		# Now find the minimum of m[1] and m[2]
		minValue=min(m[1],m[2])
		result+=minValue
		# now see whether the number div by 3 is in m[1]
		result+=((m[1]-minValue)//3)
		print(result)


if __name__=="__main__":
	t=int(input())
	for _ in range(t):
		n=int(input())
		ar=list(map(int,input().split()))
		# Now create a map
		m={}
		m[1]=0
		m[2]=0
		result=0
		for i in ar:
			if i%3==1:
				m[1]+=1
			elif i%3==2:
				m[2]+=1
			else:
				result+=1
		# Now find the minimum of m[1] and m[2]
		minValue=min(m[1],m[2])
		result+=minValue
		# now see whether the number div by 3 is in m[1]
		result+=((m[1]-minValue)//3)
		print(result)


q = int(input())

for x in range(q):
	n = int(input())
	array = list(map(int, input().split()))
	k0 = 0
	k1 = 0
	k2 = 0
	output = 0
	for z in array:
		if z % 3 == 0:
			k0+=1
		if z % 3 == 1:
			k1+=1
		if z % 3 == 2:
			k2+=1
	output+=1
	output+= min(k1,k2)
	k1-= min(k1,k2)
	k2-= min(k1,k2)
	output+= (k1 + k2)// 3
	print(output)


q = int(input())

for z in range(q):
	n = int(input())
	array = list(map(int, input().split()))
	mod_0 = 0
	mod_1 = 0
	mod_2 = 0
	output = 0

	for x in array:
		if x % 3 == 0:
			mod_0 += 1
		if x % 3 == 1:
			mod_1 += 1
		if x % 3 == 2:
			mod_2 += 1
	min_of_mod = min(mod_1,mod_2)
	output += mod_0
	output += min(mod_1,mod_2)
	mod_1 -= min_of_mod
	mod_2 -= min_of_mod
	output += (mod_1 + mod_2) // 3
	print(output)


q = int(input())

for z in range(q):
	n = int(input())
	array = list(map(int, input().split()))
	mod_0 = 0
	mod_1 = 0
	mod_2 = 0
	output = 0

	for x in array:
		if x % 3 == 0:
			mod_0 += 1
		if x % 3 == 1:
			mod_1 += 1
		if x % 3 == 2:
			mod_2 += 1

	output += mod_0
	output += min(mod_1,mod_2)
	mod_1 -= min(mod_1,mod_2)
	mod_2 -= min(mod_1,mod_2)
	output += (mod_1 + mod_2) // 3
	print(output)


q = int(input())

for x in range(q):
	n = int(input())
	array = list(map(int, input().split()))
	k0 = 0
	k1 = 0
	k2 = 0
	output = 0
	for z in array:
		if z % 3 == 0:
			k0+=1
		if z % 3 == 1:
			k1+=1
		if z % 3 == 2:
			k2+=1
	output+= k0
	output+= min(k1,k2)
	k1-= min(k1,k2)
	k2-= min(k1,k2)
	output+= (k1 + k2)// 3
	print(output)


q= int (input())
for i in range (q):
    a=int(input())
    sum=0
    list1=[0,0,0,0,0,0,0]
    for j in map(int,input().split()):
        list1[j%3]+=1
    ans=0
    ans+=min(list1[1],list1[2])
    list1[1]-=min(list1[1],list1[2])
    ans+=list1[1]//3+list1[2]//3
    ans+=list1[0]
    print(ans)


q= int (input())
for i in range (q):
    a=int(input())
    sum=0
    list1=[0,0,0,0,0,0,0]
    for j in map(int,input().split()):
        list1[j%3]+=1
    ans=0
    t=min(list1[1],list1[2])
    ans+=t
    list1[1]-=t
    list1[2] -=t
    ans+=list1[1]//3+list1[2]//3
    ans+=list1[0]
    print(ans)


q= int (input())
for i in range (q):
    a=int(input())
    sum=0
    list1=[0,0,0,0,0,0,0]
    for j in map(int,input().split()):
        list1[j%3]+=1
    ans=0
    ans+=min(list1[1],list1[2])
    list1[1]-=min(list1[1],list1[2])
    if(list1[1]>=0) : ans+=list1[1]//3
    ans+=list1[0]
    print(ans)


q= int (input())
for i in range (q):
    a=int(input())
    sum=0
    list1=[0,0,0,0,0,0,0]
    for j in map(int,input().split()):
        list1[j%3]+=1
    ans=0
    ans+=min(list1[1],list1[2])
    list1[1]-=min(list1[1],list1[2])
    list1[2] -= min(list1[1], list1[2])
    ans+=list1[1]//3+list1[2]//3
    ans+=list1[0]
    print(ans)


for i in range(int(input())):
    n=int(input())
    a=list(map(int,input().split()))
    b=[]
    c=0
    for j in range(n):
        p=a[j]%3
        if p==0:
            c+=1
        else:
            b.append(p)
    l=0
    r=len(b)-1
    b.sort()
    while l<r and b[l]==1 and b[r]==2:
        c+=1
        l+=1
        r-=1
    if l==r:
        print(c)
    else:
        if l<r and b[r]==1 and b[l]==1:
            s=sum(b[l:r+1])
            c+=(s//3)
        elif l<r and b[r]==2 and b[l]==2:
            s=sum(b[l:r+1])//2
            c+=(s//3)
        print(c)


for i in range(int(input())):
    n=int(input())
    a=list(map(int,input().split()))
    b=[]
    c=0
    for j in range(n):
        p=a[j]%3
        if p==0:
            c+=1
        else:
            b.append(p)
    l=0
    r=len(b)-1
    while l<r and b[l]==1 and b[r]==2:
        c+=1
        l+=1
        r-=1
    if l==r:
        print(c)
    else:
        if l<r and b[r]==1 and b[l]==1:
            s=sum(b[l:r+1])
            c+=(s//3)
        elif l<r and b[r]==2 and b[l]==2:
            s=sum(b[l:r+1])//2
            c+=(s//3)
        print(c)


for i in range(int(input())):
    n=int(input())
    a=list(map(int,input().split()))
    b=[]
    c=0
    for j in range(n):
        p=a[j]%3
        if p==0:
            c+=1
        else:
            b.append(p)
    l=0
    r=len(b)-1
    while l<r and b[l]==1 and b[r]==2:
        c+=1
        l+=1
        r-=1
    if l==r:
        print(c)
    else:
        if b[r]==1 and b[l]==1:
            s=sum(b[l:r+1])
            c+=(s//3)
        elif b[r]==2 and b[l]==2:
            s=sum(b[l:r+1])//2
            c+=(s//3)
        print(c)


tcase = int(input())
while tcase > 0:
    tcase -= 1
    n = int(input())
    arr = input().split()
    l = []
    for i in range(n):
        l.append(int(arr[i])%3)
    cnt1 = l.count(1)
    cnt2 = l.count(2)
    cnt0 = l.count(0)
    result = cnt0
    if cnt1 > cnt2:
        result += cnt2
        cnt1 -= cnt2
        if cnt1 >= 3:
            result += cnt1//3
    elif cnt2 > cnt1:
        result += cnt1
        cnt2 -= cnt1
        if cnt2 >= 3:
            result += cnt2//3
    elif cnt1 == cnt2:
        result += cnt1
    print(result)


tcase = int(input())
while tcase > 0:
    tcase -= 1
    n = int(input())
    arr = input().split()
    l = []
    for i in range(n):
        l.append(int(arr[i])%3)
    print(l)
    cnt1 = l.count(1)
    cnt2 = l.count(2)
    cnt0 = l.count(0)
    result = cnt0
    if cnt1 > cnt2:
        result += cnt2
        cnt1 -= cnt2
        if cnt1 >= 3:
            result += cnt1//3
    elif cnt2 > cnt1:
        result += cnt1
        cnt2 -= cnt1
        if cnt2 >= 3:
            result += cnt2//3
    elif cnt1 == cnt2:
        result += cnt1
    print(result)


tcase = int(input())
while tcase > 0:
    tcase -= 1
    n = int(input())
    arr = input().split()
    l = []
    for i in range(n):
        l.append(int(arr[i])%3)
    cnt1 = l.count(1)
    cnt0 = l.count(2)
    cnt2 = l.count(0)
    result = cnt0
    if cnt1 > cnt2:
        result += cnt2
        cnt1 -= cnt2
        if cnt1 >= 3:
            result += cnt1//3
    elif cnt2 > cnt1:
        result += cnt1
        cnt2 -= cnt1
        if cnt2 >= 3:
            result += cnt2//3
    elif cnt1 == cnt2:
        result += cnt1
    print(result)


for tt in range(int(input())):
    n = int(input())
    arr = list(map(int,input().split()))
    cnt1 = 0
    cnt2 = 0
    cnt0 = 0

    for i in range(n):
        if arr[i] % 3 == 0 :
            cnt0 +=1
        if arr[i] % 3 == 1 :
            cnt1 +=1
        if arr[i] % 3 == 2 :
            cnt2 +=1

    #print(cnt0)
    #print(cnt1)
    #print(cnt2)

    result = cnt0 + min(cnt1 , cnt2) + abs(cnt1 - cnt2) // 3
    print(result)


for tt in range(int(input())):
    n = int(input())
    arr = list(map(int,input().split()))
    print(sum(arr) // 3 )


for tt in range(int(input())):

    n = int(input())
    l = list(map(int,input().split()))
    cnt0 = 0
    cnt1 = 0
    cnt2= 0

    for i in range(n):
        if l[i] % 3 == 0 :
            cnt0 +=1

        if l[i] % 3 == 1 :
            cnt1 +=1

        if l[i] % 3 == 2 :
            cnt2 +=1

    r1 = cnt0
    r2 = min(cnt1 , cnt2)
    r3 = (max(cnt1 , cnt2) - min(cnt1 , cnt2)) // 3
    print(r1 + r2 + r3)


n=int(input())
for i in range(0,n):
    x=int(input())
    a=input().split()
    s=[int(num)for num in a]
    q=0
    for i in s:
        if i%3==0:
            q+=3
        elif i%3==1:
            q+=1
        elif i%3==2:
            q+=2
    print(q//3)


n=int(input())
for i in range(0,n):
    x=int(input())
    a=input().split()
    s=[int(num)for num in a]
    q=0
    w=0
    e=0
    for i in s:
        if i%3==0:
            q+=1
        elif i%3==1:
            w+=1
        elif i%3==2:
            e+=1
    if w>e:
        q+=e
        q+=(w-e)//3
    else:
        q+=w
        q+=(e-w)//3
    print(q)


n=int(input())
for i in range(0,n):
    x=int(input())
    a=input().split()
    s=[int(num)for num in a]
    q=0
    for i in s:
        if i%3==0:
            q+=1
        elif i%3==1:
            w+=1
        elif i%3==2:
            e+=1
    if w>e:
        q+=e
        q+=(w-e)//3
    else:
        q+=w
        q+=(e-w)//3
    print(q)


for w in range(int(input())):
    n=int(input())
    a=list(map(int,input().split()))
    l=[]
    for i in range(n):
       if(a[i]%3!=0):
           l.append(a[i]%3)
    ans=n-len(l)
    if(l.count(1)==0):
        ans+=(sum(l)//3)
    elif(l.count(2)==0):
        ans+=sum(l)//6
    elif(l.count(1)==l.count(2)):
        ans+=l.count(1)
    elif(l.count(2)>l.count(1)):
        ans+=l.count(1)
        ans+=((l.count(2)-l.count(1))//6)
    else:
        ans+=l.count(2)
        ans+=(l.count(1)-l.count(2))//3
    print(ans)


for w in range(int(input())):
    n=int(input())
    a=list(map(int,input().split()))
    l=[]
    for i in range(n):
       if(a[i]%3!=0):
           l.append(a[i]%3)
    ans=n-len(l)
    if(l.count(1)==0):
        ans+=(sum(l)//6)
    elif(l.count(2)==0):
        ans+=sum(l)//3
    elif(l.count(1)==l.count(2)):
        ans+=l.count(1)
    elif(l.count(2)>l.count(1)):
        ans+=l.count(1)
        ans+=((l.count(2)-l.count(1))//6)
    else:
        ans+=l.count(2)
        ans+=(l.count(1)-l.count(2))//3
    print(ans)


for w in range(int(input())):
    n=int(input())
    a=list(map(int,input().split()))
    l=[]
    for i in range(n):
       if(a[i]%3!=0):
           l.append(a[i]%3)
    ans=n-len(l)
    if(l.count(1)==0):
        ans+=(sum(l)//3)//2
    elif(l.count(2)==0):
        ans+=sum(l)//3
    elif(l.count(1)==l.count(2)):
        ans+=l.count(1)
    elif(l.count(2)>l.count(1)):
        ans+=l.count(1)
        ans+=((l.count(2)-l.count(1))//3)//2
    else:
        ans+=l.count(2)
        ans+=(l.count(1)-l.count(2))//3
    print(ans)


for w in range(int(input())):
    n=int(input())
    a=list(map(int,input().split()))
    l=[]
    for i in range(n):
       if(a[i]%3!=0):
           l.append(a[i]%3)
    print(n-len(l)+sum(l)//3)


for w in range(int(input())):
    n=int(input())
    a=list(map(int,input().split()))
    l=[]
    for i in range(n):
       if(a[i]%3!=0):
           l.append(a[i]%3)
    ans=n-len(l)
    if(l.count(1)==0):
        ans+=(sum(l)//3)
    elif(l.count(2)==0):
        ans+=sum(l)//3
    elif(l.count(1)==l.count(2)):
        ans+=l.count(1)
    elif(l.count(2)>l.count(1)):
        ans+=l.count(1)
        ans+=((l.count(2)-l.count(1))//3)
    else:
        ans+=l.count(2)
        ans+=(l.count(1)-l.count(2))//3
    print(ans)


for w in range(int(input())):
    n=int(input())
    a=list(map(int,input().split()))
    l=[]
    for i in range(n):
       if(a[i]%3!=0):
           l.append(a[i]%3)
    ans=n-len(l)
    if(l.count(1)==0):
        ans+=len(l)//3
    elif(l.count(2)==0):
        ans+=len(l)//3
    elif(l.count(1)==l.count(2)):
        ans+=l.count(1)
    elif(l.count(2)>l.count(1)):
        ans+=l.count(1)
        ans+=((l.count(2)-l.count(1))//3)
    else:
        ans+=l.count(2)
        ans+=(l.count(1)-l.count(2))//3
    print(ans)


t = int(input())
for i in range(t):
    n = int(input())
    arr = list(map(int, input().split()))
    arr1 = [0, 0, 0]
    for j in range(n):
        arr1[arr[j] % 3] += 1
    ans = arr1[0]
    ans1 = ans
    ans1 += arr1[1] // 3
    ans1 += arr1[2] // 3
    k = min(arr1[1], arr1[2])
    ans += k
    arr1[1] -= k
    arr1[2] -= k
    ans += arr1[1] // 3
    ans += arr1[2] // 3
    print(max(ans, ans1))


t = int(input())
for i in range(t):
    n = int(input())
    arr = list(map(int, input().split()))
    arr1 = [0, 0, 0]
    for j in range(n):
        arr1[arr[j] % 3] += 1
    ans = arr1[0]
    ans += min(arr1[1], arr1[2])
    arr1[1] -= min(arr1[1], arr1[2])
    arr1[2] -= min(arr1[1], arr1[2])
    ans += arr1[1] // 3
    ans += arr1[2] // 3
    print(ans)


t = int(input())
for i in range(t):
    n = int(input())
    arr = list(map(int, input().split()))
    arr1 = [0, 0, 0]
    for j in range(n):
        arr1[arr[j] % 3] += 1
    ans = arr1[0]
    ans1 = ans
    ans1 += arr1[1] // 3
    ans1 += arr1[2] // 3
    ans += min(arr1[1], arr1[2])
    arr1[1] -= min(arr1[1], arr1[2])
    arr1[2] -= min(arr1[1], arr1[2])
    ans += arr1[1] // 3
    ans += arr1[2] // 3
    print(max(ans, ans1))


from collections import Counter

for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = Counter([j % 3 for j in a])
	if c[1] > c[2]:
		l = (c[1] - c[2]) // 3
		c[1] -= 2 * l
		c[2] += l
	elif c[2] > c[1]:
		l = (c[1] - c[2]) // 3
		c[2] -= 2 * l
		c[1] += l
	print(c[0] + min(c[1], c[2]))


from collections import Counter

for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = Counter([j % 3 for j in a])
	if c[1] > c[2]:
		l = (c[1] - c[2]) // 3
		c[1] -= 2 * l
		c[2] += l
	elif c[2] > c[1]:
		l = (c[2] - c[1]) // 3
		c[2] -= 2 * l
		c[1] += l
	print(c[0] + min(c[1], c[2]))


from collections import Counter

for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = Counter([j % 3 for j in a])
	if c[1] > c[2]:
		l = (c[1] - c[2]) // 3
		c[1] -= 2 * l
		c[2] += l
	print(c[0] + min(c[1], c[2]))


t = int(input())
for i in range(t):
  a = int(input())
  s = [int(x) % 3 for x in input().split() if int(x) != 0]
  ans = s.count(0) + min(s.count(1), s.count(2)) + (s.count(1) - (min(s.count(1), s.count(2)))) // 3 + (s.count(2) - min(s.count(1), s.count(2))) // 3 * 2
  print(ans)


t = int(input())
for i in range(t):
  a = int(input())
  s = [int(x) % 3 for x in input().split() if int(x) != 0]
  print(s)
  ans = s.count(0) + min(s.count(1), s.count(2)) + (s.count(1) - (min(s.count(1), s.count(2)))) // 3 + (s.count(2) - min(s.count(1), s.count(2))) // 3 * 2
  print(ans)


t = int(input())
for i in range(t):
  a = int(input())
  s = [int(x) % 3 for x in input().split() if int(x) != 0]
  ans = s.count(0) + min(s.count(1), s.count(2)) + (s.count(1) - (min(s.count(1), s.count(2)))) // 3 + (s.count(2) - min(s.count(1), s.count(2))) // 3
  print(ans)


t = int(input())
for i in range(t):
  a = int(input())
  s = [int(x) % 3 for x in input().split() if int(x) != 0]
  ans = s.count(0) + min(s.count(1), s.count(2)) + (s.count(1) - (min(s.count(1), s.count(2)))) // 3
  print(ans)


import sys
import math
from collections import defaultdict

def rl():
    return sys.stdin.readline().strip()

def rn():
    return list(map(int, sys.stdin.readline().strip().split()))

def rln(n):
    l = [None] * n
    for i in range(n):
        l[i] = int(rl())
    return l

def solve():
    input()
    tab = rn()
    count1 = 0
    count2 = 0
    res = 0
    for e in tab:
        if e % 3 == 0:
            res += 1
        elif e % 3 == 1:
            count1 += 1
        elif e % 3 == 2:
            count2 += 1
    if count2 >= count1:
        print(res + count1)
    else:
        print(res + count2 + (count1 - count2) // 3)

if __name__ == '__main__':
    test = int(input())
    for _ in range(test):
        solve()


import sys
import math
from collections import defaultdict

def rl():
    return sys.stdin.readline().strip()

def rn():
    return list(map(int, sys.stdin.readline().strip().split()))

def rln(n):
    l = [None] * n
    for i in range(n):
        l[i] = int(rl())
    return l

def solve():
    input()
    tab = rn()
    count1 = 0
    count2 = 0
    res = 0
    for e in tab:
        if e % 3 == 0:
            res += 1
        elif e % 3 == 1:
            count1 += 1
        elif e % 3 == 2:
            count2 += 1
    if count2 >= count1:
        print(res + count1 + (count2 - count1) // 3)
    else:
        print(res + count2 + (count1 - count2) // 3)

if __name__ == '__main__':
    test = int(input())
    for _ in range(test):
        solve()


import sys
import math
from collections import defaultdict

def rl():
    return sys.stdin.readline().strip()

def rn():
    return list(map(int, sys.stdin.readline().strip().split()))

def rln(n):
    l = [None] * n
    for i in range(n):
        l[i] = int(rl())
    return l

def solve():
    input()
    tab = rn()
    count1 = 0
    count2 = 0
    res = 0
    for e in tab:
        if e % 3 == 0:
            res += 1
        elif e % 3 == 1:
            count1 += 1
        elif e % 3 == 2:
            count2 += 1
    if count2 >= count1:
        print(res + count1 + (count1 - count2) // 3)
    else:
        print(res + count2 + (count1 - count2) // 3)

if __name__ == '__main__':
    test = int(input())
    for _ in range(test):
        solve()


t=int(input())
for j in range(t):
    n=int(input())
    li=list(map(int,input().split()))
    for i in range(n):
        li[i]=li[i]%3
        z=li.count(0)
        a=li.count(1)
        b=li.count(2)
        if(a>b):
            z=z+b
            a=a-b
            z=z+(a//3)
        else:
            z=z+b
            b=b-a
            z=z+(b//3)
    print(z)


t=int(input())
for j in range(t):
    n=int(input())
    li=list(map(int,input().split()))
    for i in range(n):
        li[i]=li[i]%3
    z=li.count(0)
    a=li.count(1)
    b=li.count(2)
    if(a>b):
        z=z+b
        a=a-b
        z=z+(a//3)
    else:
        z=z+b
        b=b-a
        z=z+(b//3)
    print(z)


t=int(input())
for j in range(t):
    n=int(input())
    li=list(map(int,input().split()))
    for i in range(n):
        li[i]=li[i]%3
    z=li.count(0)
    a=li.count(1)
    b=li.count(2)
    if(a>b):
        z=z+b
        a=a-b
        z=z+(a//3)
    else:
        z=z+a
        b=b-a
        z=z+(b//3)
    print(z)


for t in range(int(input())):
  n, d = input(), [0, 0, 0]
  for num in map(int,input().split()):
    d[num%3] += 1
    m = min((d[1], d[2]))
  print(d[0]+m+(d[1]-m)//3)


def sum_of(n):
	s = 0
	num = n
	while(num>0):
		s+=num%10
		num = num//10
	return s
for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	x_0 = 0
	x_1 = 0
	x_2 = 0
	for i in range(n):
		temp = sum_of(l[i])
		if(temp%3 == 0):
			x_0 += 1
		elif((temp-1)%3 == 0):
			x_1 += 1
		else:
			x_2+=1
	temp = min(x_1, x_2)
	count = x_0 + temp
	x_1-=temp
	x_2-=temp
	count += x_1//3
	count += x_2//3
	print(count)


def sum_of(num):
	s = 0
	while(num>0):
		s+=num%10
		num = num//10
	return s
for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	x_0 = 0
	x_1 = 0
	x_2 = 0
	for i in range(n):
		temp = sum_of(l[i])
		if(temp%3 == 0):
			x_0+=1
		elif((temp-1)%3 == 0):
			x_1+=1
		else:
			x_2+=1
	print(x_0 + min(x_1,x_2))


def sum_of(num):
	s = 0
	while(num>0):
		s+=num%10
		num = num//10
	return s
for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	x_0 = 0
	x_1 = 0
	x_2 = 0
	for i in range(n):
		temp = sum_of(l[i])
		if(temp%3 == 0):
			x_0+=1
		elif((temp-1)%3 == 0):
			x_1+=1
		else:
			x_2+=1
	count = x_0 + min(x_1,x_2)
	x_1 -= min(x_1, x_2)
	x_2 -= min(x_1, x_2)
	count += x_1//3
	count += x_2//3
	print(count)


#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin>>n;
    int a[n],p[n];
    int minp = INT_MAX,mini;
    for(int i=0;i<n;i++){
        cin>>a[i]>>p[i];
        if(minp>p[i]){
            mini = i;
            minp = p[i];
        }
    }
    int ans = 0;
    for(int i=0;i<=mini;i++){
        ans+=a[i]*p[i];}
    for(int i=mini+1;i<n;i++)
        ans+=a[i]*minp;
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
    int n ; cin >>n ;
    int mi = 1000000 ;
    int ans = 0 ;
    while(n--){
        int a,p ;  cin>>a>>p ;
        mi=min(mi,p) ;
        ans+=mi*a;
    }
    cout<<ans<<endl ;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin>>n;
    int a[n],p[n];
    int minp = INT_MAX;
    int mini;
    for(int i=0;i<n;i++){
        cin>>a[i]>>p[i];
        if(minp>p[i]){
            mini = i;
            minp = p[i];
        }
    }
    long long ans = 0;
    for(int i=0;i<n;i++){
        if(i<=mini)ans+=a[i]*p[i];
        else ans+=a[i]*minp;
    }
    cout<<ans<<endl;
    return 0;
}


#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
int main(){
	int N;
	scanf("%d",&N);
	int a,p;
	int ans=0;
	int pd=0x7fffffff;
	for(int i=0;i<N;i++){
		scanf("%d  %d",&a,&p);
		if(pd>p){
			pd=p;
		}
		ans+=pd*a;
	}
	printf("%d\n",ans);
	return 0;

}


#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
int main(){
	int N;
	cin>>N;
	int a[110]={},p[110]={};
	cin>>a[0]>>p[0];
	int ans=a[0]*p[0];
	int pd=p[0];
	for(int i=1;i<N;i++){
		cin>>a[i]>>p[i];
		pd=min(pd,p[i]);
		ans+=pd*a[i];
	}
	cout<<ans<<endl;

	return 0;

}


#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
int main(){
	int N;
	scanf("%d",&N);
	int a[110]={},p[110]={};
	scanf("%d",&a[0]);
	scanf("%d",&p[0]);
	int ans=a[0]*p[0];
	int pd=p[0];
	for(int i=1;i<N;i++){
		scanf("%d",&a[i]);
		scanf("%d",&p[i]);
		pd=min(pd,p[i]);
		ans+=pd*a[i];
	}
	printf("%d",&N);
	return 0;

}


#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
int main(){
	int N;
	scanf("%d",&N);
	int a[110]={},p[110]={};
	int ans=0;
	int pd=0x7fffffff;
	for(int i=0;i<N;i++){
		scanf("%d  %d",&a[i],&p[i]);
		if(pd>p[i]){
			pd=p[i];
		}
		ans+=pd*a[i];
	}
	printf("%d\n",ans);
	return 0;

}


#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
int main(){
	int N;
	scanf("%d",&N);
	int a[110]={},p[110]={};
	scanf("%d",&a[0]);
	scanf("%d",&p[0]);
	int ans=a[0]*p[0];
	int pd=p[0];
	for(int i=1;i<N;i++){
		scanf("%d",&a[i]);
		scanf("%d",&p[i]);
		pd=min(pd,p[i]);
		ans+=pd*a[i];
	}
	printf("%d",ans);
	return 0;

}


#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
int main(){
	int N;
	scanf("%d",&N);
	int a[110]={},p[110]={};
	scanf("%d",&a[0]);
	scanf("%d",&p[0]);
	int ans=a[0]*p[0];
	int pd=p[0];
	for(int i=1;i<N;i++){
		scanf("%d",&a[i]);
		scanf("%d",&p[i]);
		if(pd>p[i]){
			pd=p[i];
		}
		ans+=pd*a[i];
	}
	printf("%d",ans);
	return 0;

}


#include <iostream>
using namespace std;
int main()
{
   int n;
   int a[n];
   int p[n];
   cin>>n;
   cin>>a[0];
   cin>>p[0];
   int min=p[0];
   int minindex=0;
   int sum=0;
   for(int i=1;i<n;i++)
   {
       cin>>a[i];
       cin>>p[i];
       if(min>p[i])
       {

           min=p[i];
           minindex=i;
       }
   }
   for(int i=0;i<minindex;i++)
   {
       sum+=p[i]*a[i];

   }
   for(int i=minindex;i<n;i++)
   {
       sum+=min*a[i];

   }

   cout<<sum;

    return 0;
}


#include <iostream>
using namespace std;
int main()
{
   int n;

   cin>>n;
   int a[n];
   int p[n];
   cin>>a[0];
   cin>>p[0];
   int min=p[0];
   int minindex=0;
   long long sum=0;
   sum+=a[0]*p[0];
   for(int i=1;i<n;i++)
   {
       cin>>a[i];
       cin>>p[i];
       if(min>p[i])
       {
           sum+=p[i]*a[i];
           min=p[i];
           minindex=i;
       }
       else
        sum+=min*a[i];
   }

   cout<<sum;

  /*10 5
  98 7
  54 7
  54 3
  100 1
  68 4*/

 /*  for(int i=0;i<minindex;i++)
   {
       sum+=p[i]*a[i];

   }
   for(int i=minindex;i<n;i++)
   {
       sum+=min*a[i];

   }*/

    return 0;
}


#include <iostream>
using namespace std;
int main()
{
   int n;

   cin>>n;
   int a[n];
   int p[n];
   cin>>a[0];
   cin>>p[0];
   int min=p[0];
   int minindex=0;
   long long sum=0;
   for(int i=1;i<n;i++)
   {
       cin>>a[i];
       cin>>p[i];
       if(min>p[i])
       {

           min=p[i];
           minindex=i;
       }
   }
   for(int i=0;i<minindex;i++)
   {
       sum+=p[i]*a[i];

   }
   for(int i=minindex;i<n;i++)
   {
       sum+=min*a[i];

   }

   cout<<sum;

    return 0;
}


#include <iostream>
using namespace std;
int main()
{
   int n;
   int a[n];
   int p[n];
   cin>>n;
   cin>>a[0];
   cin>>p[0];
   int min=p[0];
   int minindex=0;
   long sum=0;
   for(int i=1;i<n;i++)
   {
       cin>>a[i];
       cin>>p[i];
       if(min>p[i])
       {

           min=p[i];
           minindex=i;
       }
   }
   for(int i=0;i<minindex;i++)
   {
       sum+=p[i]*a[i];

   }
   for(int i=minindex;i<n;i++)
   {
       sum+=min*a[i];

   }

   cout<<sum;

    return 0;
}


#include <iostream>
using namespace std;
int main()
{
   int n;
   int a[100005];
   int p[100005];
   cin>>n;
   cin>>a[0];
   cin>>p[0];
   int min=p[0];
   int minindex=0;
   int sum=0;
   for(int i=1;i<n;i++)
   {
       cin>>a[i];
       cin>>p[i];
       if(min>p[i])
       {

           min=p[i];
           minindex=i;
       }
   }
   for(int i=0;i<minindex;i++)
   {
       sum+=p[i]*a[i];

   }
   for(int i=minindex;i<n;i++)
   {
       sum+=min*a[i];

   }

   cout<<sum;

    return 0;
}


#include <iostream>
using namespace std;
int main()
{
   int n;
   int a[n];
   int p[n];
   cin>>n;
   cin>>a[0];
   cin>>p[0];
   int min=p[0];
   int minindex=0;
   long sum=0;
   for(int i=1;i<n;i++)
   {
       cin>>a[i];
       cin>>p[i];
       if(min>p[i])
       {

           min=p[i];
           minindex=i;
       }
   }
   for(int i=0;i<minindex;i++)
   {
       sum+=p[i]*a[i];
      // cout<<"sum: "<<sum<<endl;
   }
   for(int i=minindex;i<n;i++)
   {
       sum+=min*a[i];
      // cout<<"sum: "<<sum<<endl;
   }

   cout<<sum;

    return 0;
}


#include <iostream>
using namespace std;
int main()
{
   int n;
   int a[n];
   int p[n];
   cin>>n;
   cin>>a[0];
   cin>>p[0];
   int min=p[0];
   int minindex=0;
   long long sum=0;
   for(int i=1;i<n;i++)
   {
       cin>>a[i];
       cin>>p[i];
       if(min>p[i])
       {

           min=p[i];
           minindex=i;
       }
   }
   for(int i=0;i<minindex;i++)
   {
       sum+=p[i]*a[i];

   }
   for(int i=minindex;i<n;i++)
   {
       sum+=min*a[i];

   }

   cout<<sum;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+9;
int a[maxn],p[maxn];
int main()
{
    int n;
    int a[maxn],p[maxn];
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i]>>p[i];
    }
    int ans=p[1];
    int sum=a[1]*ans;
    for(int i=2;i<=n;i++){
        if(p[i]<ans){
            ans=p[i];
            sum+=a[i]*ans;
        }
        else sum+=a[i]*ans;
    }
    cout<<sum;

	return 0;
}


#include<iostream>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
const int MAXN = 17;
const int oo = 1e9+7;
int main()
{
    int N;
    while(scanf("%d", &N) != EOF)
    {
        int ai, pi, ans=0, MinP=oo;
        while(N--)
        {
            scanf("%d%d", &ai, &pi);
            MinP = min(MinP, pi);
            ans += ai * MinP;
        }
        printf("%d\n", ans);
    }
    return 0;
}


#include<iostream>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;

const int MAXN = 17;
const int oo = 1e9+7;

int main()
{
    int N;

    while(scanf("%d", &N) != EOF)
    {
        int ai, pi, ans=0, MinP=oo;

        while(N--)
        {
            scanf("%d%d", &ai, &pi);
            MinP = min(MinP, pi);
            ans += ai * MinP;
        }

        printf("%d\n", ans);
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,a,b,now=0x7fffffff;
long long ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d%d",&a,&b);
		now=min(now,b);
		ans+=now*a;
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[100005],b[100005];
int n,ans,sum;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>b[i]>>a[i];
    ans=a[1];
    sum=b[1]*ans;
    for(int i=2;i<=n;i++)
    if(a[i]<ans){
        ans=a[i];
        sum+=b[i]*ans;
    }
    else
        sum+=b[i]*ans;
	cout<<sum;
}


#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
map<int,int>mp;
int n,a[105],p[105],ans,sum;
int main()
{   cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i]>>p[i];
    ans=p[0];
    sum=a[0]*ans;
    for(int i=1;i<n;i++)
    {
        if(p[i]<ans)
        {
            ans=p[i];
            sum+=a[i]*ans;
        }
        else sum+=a[i]*ans;
    }
    cout<<sum<<endl;

	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n,ans=0,a,p,minn=3e7;
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d%d",&a,&p);
		minn=min(minn,p);
		ans+=minn*a;
	}
	printf("%d",ans);
	return 0;
}


#include<iostream> using namespace std; int main() { int n,x,y,sum=0,x1,y1; cin>>n; cin>>x>>y; x1=x;y1=y; for(int i=1;i<n;i++) { cin>>x>>y; if(y1>y) { sum+=x1*y1; y1=y; x1=x; } else { sum+=x1*y1; x1=x; } } cout<<sum+x1*y1<<endl; return 0; }


#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
using namespace std;
int main()
{
	int n,s1,s2;
	vector<int> a,p;
	cin >>n;
	for(int i = 0;i<n;i++)
	{
		cin >> s1 >> s2;
		a.push_back(s1);
		p.push_back(s2);
	}
	int a1 = a[0],p1 = p[0],cost = 0,totalcost = 0;
	for(int i = 1;i<n;i++)
	{
		if(p1 >= p[i])
		{
			cost = p1 * a1;
			p1 = p[i];
			a1 = a[i];
			totalcost += cost;
		}
		else
		{
			a1 += a[i];
		}
		if(i == n-1)
		{
			cost = p1 * a1;
			totalcost += cost;
		}
	}
	cout << totalcost;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
using namespace std;
int main()
{
	int n,s1,s2;
	vector<int> a,p;
	cin >>n;
	for(int i = 0;i<n;i++)
	{
		cin >> s1 >> s2;
		a.push_back(s1);
		p.push_back(s2);
	}
	int a1 = a[0],p1 = p[0],cost = 0,totalcost = 0;
	for(int i = 1;i<n;i++)
	{
		if(p1 >= p[i])
		{
			cost = p1 * a1;
			p1 = p[i];
			a1 = a[i];
			totalcost += cost;
		}
		else
		{
			a1 += a[i];
		}
		if(i == n-1)
		{
			cost = p1 * a1;
			totalcost += cost;
		}
	}
	if( n == 1)
		totalcost = a1 * p1;
	cout << totalcost;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
#include<map>
#include<iterator>
#include<utility>

using namespace std;
int main()
{
	int n,a[100001],p[100001];
	cin >> n;
	for(int i = 0; i < n ;i++)
	{
		cin >> a[i] >> p[i];
	}
	sort(p,p+n);
	int st = n-1,suma = a[n-1],j = 0,cost = 0,totalcost = 0;
	for(int i = n-1; i > 0 ; i--)
	{
		if(a[i] !=  p[j])
		{
			suma += a[i];
		}
		if(a[i] == p[j] || i == 0)
		{
			suma += a[i];
			cost = suma*p[j];
			totalcost += cost;
			j++;
		}
	}
}


#include <bits/stdc++.h>
using namespace std;

int main() {
long long int n,i,j,k;
cin>>n;
long long int a[n][2];
for(i=0;i<n;i++)
{
cin>>a[i][0];
cin>>a[i][1];
}
long long int sum=0,sum1=0;
//cout<<sum1;
for(i=0;i<n;)
{
    //cout<<i<<" ";
    sum=a[i][0];
   // cout<<sum<<" ";
    j=i+1;
   // cout<<j<<" ";
    k=1;
    while(a[j][1]>a[i][1] && j<n)
    {
        sum+=a[j][0];
     //   cout<<sum<<" ";
        j++;
        k++;
    }
    sum1+=sum*a[i][1];

   // cout<<sum1<<"\n";
    i+=k;
}
cout<<sum1<<"\n";
}


#include <iostream>
using namespace std;

int main() {
long long int n,t,i,j,sum=0,sum1=0,k;
cin>>n;
long long int a[n][2];
for(i=0;i<n;i++)
cin>>a[i][0]>>a[i][1];
for(i=0;i<n;)
{
    sum=a[i][0];
    j=i+1;
    k=1;
    while(a[j][1]>=a[i][1])
    {
        sum+=a[j][0];
        j++;
        k++;
    }
    sum1+=sum*a[i][1];
    //cout<<sum1<<" ";
    i+=k;
}
cout<<sum1;
}


#include <iostream>
using namespace std;

int main() {
long long int n,t,i,j,sum=0,sum1=0,k;
cin>>n;
long long int a[n][2];
for(i=0;i<n;i++)
cin>>a[i][0]>>a[i][1];
for(i=0;i<n;)
{
    sum=a[i][0];
    j=i+1;
    k=1;
    while(a[j][1]>a[i][1])
    {
        sum+=a[j][0];
        j++;
        k++;
    }
    sum1+=sum*a[i][1];
    //cout<<sum1<<" ";
    i+=k;
}
cout<<sum1<<"\n";
}


#include <iostream>
using namespace std;

int main() {
long long int n,t,i,j,sum=0,sum1=0,k;
cin>>n;
long long int a[n][2];
for(i=0;i<n;i++)
cin>>a[i][0]>>a[i][1];
for(i=0;i<n;)
{
    sum=a[i][0];
    j=i+1;
    k=1;
    while(a[j][1]>a[i][1])
    {
        sum+=a[j][0];
        j++;
        k++;
    }
    sum1+=sum*a[i][1];
    //cout<<sum1<<" ";
    i+=k;
}
cout<<sum1;
}


#include <bits/stdc++.h>

using namespace std;
pair<int, int> pa[11111];
int main(){
	long long n,a,s,d=0,f;
	cin >> n;
	for(int i=0 ; i<n ; i++){
		cin >> pa[i].first >> pa[i].second;
	}
	int j;
	for(int i=0 ; i<n ; i++){
		j=i+1;
		s=pa[i].first;
		while(pa[i].second<=pa[j].second){
			s=s+pa[j].first;
			j++;
		}
		j--;
		d=d+s*pa[i].second;
		i=j;
	}
	cout << d;
return 0;
}


#include <bits/stdc++.h>

using namespace std;
pair<int, int> pa[111111];
int main(){
	long long n,a,s,d=0,f;
	cin >> n;
	for(int i=0 ; i<n ; i++){
		cin >> pa[i].first >> pa[i].second;
	}
	int j;
	for(int i=0 ; i<n ; i++){
		j=i+1;
		s=pa[i].first;
		while(pa[i].second<=pa[j].second){
			s=s+pa[j].first;
			j++;
		}
		j--;
		d=d+s*pa[i].second;
		i=j;
	}
	cout << d;
return 0;
}


#include <bits/stdc++.h>

using namespace std;
pair<int, int> pa[1111];
int main(){
	long long n,a,s,d=0,f;
	cin >> n;
	for(int i=0 ; i<n ; i++){
		cin >> pa[i].first >> pa[i].second;
	}
	int j;
	for(int i=0 ; i<n ; i++){
		j=i+1;
		s=pa[i].first;
		while(pa[i].second<=pa[j].second){
			s=s+pa[j].first;
			j++;
		}
		j--;
		d=d+s*pa[i].second;
		i=j;
	}
	cout << d;
return 0;
}


#include <bits/stdc++.h>

using namespace std;
pair<int,int> q[100001];
int main(){
	long long n,s=0;
	int w[1000];
	cin >> n;
	w[0]=10000000;
	for(int i=1 ; i<=n ; i++){
		cin >> q[i].first >> q[i].second;
		w[i]=min(q[i].second,w[i-1]);
	}
	for(int i=1 ; i<=n ; i++){
		s=s+q[i].first*w[i];
	}
	cout << s;
return 0;
}


#include <bits/stdc++.h>

using namespace std;
pair<long long ,long long> q[100001];
int main(){
	long long n,s=0;
	long long w[1000];
	cin >> n;
	w[0]=10000000;
	for(int i=1 ; i<=n ; i++){
		cin >> q[i].first >> q[i].second;
		w[i]=min(q[i].second,w[i-1]);
	}
	for(int i=1 ; i<=n ; i++){
		s=s+q[i].first*w[i];
	}
	cout << s;
return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int a[1000],p[1000],n,min1=INT_MAX,tmp=0,ans=0;
    cin>>n;
    for(int i = 0 ; i < n ; i++)cin>>a[i]>>p[i];
    if(n==1){ans=a[0]*p[0];cout<<ans;return 0;}
    for(int i = 0 ; i < n ; i++){
        if(p[i]<min1)min1=p[i];
    }

    for(int i = 0 ; i < n ; i++){
        if(p[i]==min1){tmp=i;break;}
        ans+=(a[i]*p[i]);

    }

    for(int i = tmp ; i < n ; i++){
        ans+=a[i];

    }
    cout<<ans;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int a[1000],p[1000],n,min1=INT_MAX,tmp=0,ans=0;
    cin>>n;
    for(int i = 0 ; i < n ; i++)cin>>a[i]>>p[i];

    for(int i = 0 ; i < n ; i++){
        if(p[i]<min1){min1=p[i];tmp=i;}

    }

    if(tmp==n-1){min1=INT_MAX;tmp=INT_MAX;}

    for(int i = 0 ; i < n ; i++){
        if(p[i]==min1){tmp=i;break;}
        ans+=(a[i]*p[i]);

    }
if(tmp!=INT_MAX){
    for(int i = tmp ; i < n ; i++){
        ans+=a[i]*p[tmp];

    }
}
    cout<<ans;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int a[1000],p[1000],n,min1=INT_MAX,tmp=0,ans=0;
    cin>>n;
    for(int i = 0 ; i < n ; i++)cin>>a[i]>>p[i];
    for(int i = 0 ; i < n ; i++){
        if(p[i]<min1)min1=p[i];
    }

    for(int i = 0 ; i < n ; i++){
            if(p[i]==min1){tmp=i;break;}
        ans+=(a[i]*p[i]);

    }

    for(int i = tmp ; i < n ; i++){
        ans+=a[i];

    }
    cout<<ans;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int a[1000],p[1000],n,min1=INT_MAX,tmp=0,ans=0;
    cin>>n;
    for(int i = 0 ; i < n ; i++)cin>>a[i]>>p[i];

    for(int i = 0 ; i < n ; i++){
        if(p[i]<min1){min1=p[i];tmp=i;}

    }
    if(tmp==n-1){min1=INT_MAX;tmp=0;}

    for(int i = 0 ; i < n ; i++){
        if(p[i]==min1){tmp=i;break;}
        ans+=(a[i]*p[i]);

    }
if(tmp!=0){
    for(int i = tmp ; i < n ; i++){
        ans+=a[i];

    }
}
    cout<<ans;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int a[1000],p[1000],n,min1=INT_MAX,tmp=0,ans=0;
    cin>>n;
    for(int i = 0 ; i < n ; i++)cin>>a[i]>>p[i];
    for(int i = 0 ; i < n ; i++){
        ans+=a[i]*p[i];
        if(p[i]<p[i+1])p[i+1]=p[i];
    }

    cout<<ans;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    long long a[100001],p[100001],n,min1=INT_MAX,tmp=0,ans=0;
    cin>>n;
    for(int i = 0 ; i < n ; i++)cin>>a[i]>>p[i];
    for(int i = 0 ; i < n ; i++){
        ans+=a[i]*p[i];
        if(p[i]<p[i+1])p[i+1]=p[i];
    }

    cout<<ans;

    return 0;
}


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

int sum(int* A, int lo, int hi){
    int r=0;
    for(int i=lo;i<hi;i++)
      r+= *(A+i);
    return r;
}

int f(int* P, int hi, int n, int* A){
    int* t = min_element(P, P+hi);
    int z = t - P;
    return (*t)*sum(A, z, n) + f(P, z, n, A);
}

int main(){
    int n;
    int A[100000], P[100000];
    cin >> n;
    for(int i=0;i<n;i+)
      cin >> A[i] >> P[i];
    cout << f(P, n, n, A);
    return 0;
}


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

int sum(int* A, int lo, int hi){
    int r=0;
    for(int i=lo;i<hi;i++)
      r+= *(A+i);
    return r;
}

int f(int* P, int hi, int n, int* A){
    int* t = min_element(P, P+hi);
    int z = t - P;
    return (*t)*sum(A, z, n) + f(P, z, n, A);
}

int main(){
    int n;
    int A[100000], P[100000];
    cin >> n;
    for(int i=0;i<n;i++)
      cin >> A[i] >> P[i];
    cout << f(P, n, n, A);
    return 0;
}


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

int sum(int* A, int lo, int hi){
    int r=0;
    for(int i=lo;i<hi;i++)
      r+= *(A+i);
    return r;
}

int f(int* P, int hi, int* A){
    int* t = min_element(P, P+hi);
    int z = t - P;
    if(z==0){
        return (*t)*sum(A, z, hi)
    }
    return (*t)*sum(A, z, hi) + f(P, z, A);
}

int main(){
    int n;
    int A[100000], P[100000];
    cin >> n;
    for(int i=0;i<n;i++)
      cin >> A[i] >> P[i];
    cout << f(P, n, n, A);
    return 0;
}


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

int sum(int* A, int lo, int hi){
    int r=0;
    for(int i=lo;i<hi;i++)
      r+= *(A+i);
    return r;
}

int f(int* P, int hi, int* A){
    int* t = min_element(P, P+hi);
    int z = t - P;
    if(z==0){
        return (*t)*sum(A, z, hi)
    }
    return (*t)*sum(A, z, hi) + f(P, z, A);
}

int main(){
    int n;
    int A[100000], P[100000];
    cin >> n;
    for(int i=0;i<n;i++)
      cin >> A[i] >> P[i];
    cout << f(P, n, A);
    return 0;
}


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

int sum(int* A, int lo, int hi){
    int r=0;
    for(int i=lo;i<hi;i++)
      r+= *(A+i);
    return r;
}

int f(int* P, int hi, int* A){
    int* t = min_element(P, P+hi);
    int z = t - P;
    if(z==0){
        return (*t)*sum(A, z, hi);
    }
    return (*t)*sum(A, z, hi) + f(P, z, A);
}

int main(){
    int n;
    int A[100000], P[100000];
    cin >> n;
    for(int i=0;i<n;i++)
      cin >> A[i] >> P[i];
    cout << f(P, n, A);
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
    ll n,l,i,ans=0,c=0,v=0;;

    cin>>n;
    ll a[n],p[n];
    for(i=0;i<n;i++)
    {cin>>a[i]>>p[i];}

    sort(a,a+n);

   for(i=0;i<n;i++){
       c=0;v=p[i];
       while(v<=p[i] &&i<n){
           c+=a[i];
           i++;
       }i--;
       ans+=(c*v);
   }
    cout<<ans;

    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
    ll n,l,i,ans=0,c=0,v=0;;

    cin>>n;
    ll a[n],p[n];
    for(i=0;i<n;i++)
    {cin>>a[i]>>p[i];}

    sort(a,a+n);cout<<ans;
   for(i=0;i<n;i++){
       c=0;v=p[i];
       while(v<=p[i]){
           c+=a[i];
           i++;
       }i--;
       ans+=(c*v);
   }
    cout<<ans;

    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
    ll n,l,i,ans=0,c=0,v=0;;

    cin>>n;
    ll a[n],p[n];
    for(i=0;i<n;i++)
    {cin>>a[i]>>p[i];}

    sort(a,a+n);
   for(i=0;i<n;i++){
       c=0;v=p[i];
       while(v<=p[i]){
           c+=a[i];
           i++;
       }i--;
       ans+=c*v;
   }
    cout<<ans;

    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
    ll n,l,i,ans=0,c=0,v=0;;

    cin>>n;
    ll a[n],p[n];
    for(i=0;i<n;i++)
    {cin>>a[i]>>p[i];}

    sort(a,a+n);
   for(i=0;i<n;i++){
       c=0;v=p[i];
       while(v<=p[i]){
           c+=a[i];
           i++;
       }i--;
       ans+=(c*v);
   }
    cout<<ans;

    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
    ll n,l,i,ans=0,c=0,v=0;;

    cin>>n;
    ll a[n],p[n];
    for(i=0;i<n;i++)
    {cin>>a[i]>>p[i];}

   // sort(a,a+n);

   for(i=0;i<n;i++){
       c=0;v=p[i];
       while(v<=p[i] &&i<n){
           c+=a[i];
           i++;
       }i--;
       ans+=(c*v);
   }
    cout<<ans;

    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
    ll n,l,i,ans=0,c=0,v=0;;

    cin>>n;
    ll a[n],p[n];
    for(i=0;i<n;i++)
    {cin>>a[i]>>p[i];}

    sort(a,a+n);
    ans=0;
   for(i=0;i<n;i++){
       c=0;v=p[i];
       while(v<=p[i]){
           c+=a[i];
           i++;
       }i--;
       ans+=(c*v);
   }
    cout<<ans;

    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
    ll n,l,i,ans=0,c=0,v=0;;

    cin>>n;
    ll a[n],p[n];
    for(i=0;i<n;i++)
    {cin>>a[i]>>p[i];}

    sort(a,a+n);
   for(i=0;i<n;i++){
       c=0;v=p[i];
       while(v<=p[i]){
           c=c+a[i];
           i++;
       }i--;
       ans=ans+(c*v);
   }
    cout<<ans;

    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int main () {
    int n, s = 0, min = 1000000, mn = 0, fl = 0;
    cin >> n;
    vector <int> a(n); vector <int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> p[i];
        if (p[i] < min) {
            min = p[i]; mn = i;
        }
    }
    for (int i = 0; i < n; i++) {
        if (fl == 0)
        if (i != mn) {
            s+= a[i] * p[i];
    } else { for (int j = i; j < n; j++) { s+= a[j] * min; } fl++; }
    }
    cout << s;
}


#include <iostream>
#include <vector>
using namespace std;
int main () {
    int n;
    cin >> n;
    vector <int> a(n);
    vector <int> p(n);
    vector <int> pf(n);
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> p[i];
    }
    for (int i = 1; i <= n; i++) {
        pf[i] = p[i];
    }
    sort (pf);
    int min = 0;
    for (int i = 1; i <= n; i++) {
        if (p[i] == pf[1]) {
            min = i;
            break;
        }
    }
    for (int i = 1; i <= n; i++) {
        if (i != max && fl == 0) {
            sum+= a[i] * p[i];
        } else { for (int j = i; j <= n; j++) { sum+= a[j] * min; } fl++; }
    }
    cout << sum;
}


#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, sum = 0;
    cin >> n;
    vector <int> a(n);
    vector <int> p(n + 1);
    vector <bool> used (n, false);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cin >> p[i];
    }
    for (int i = 0; i < n; i++) {
        if (p[i] < p[i + 1]) {
            if (used[i] == false) {
            sum+= ((a[i] + a[i + 1]) * p[i]);
            used[i + 1] = true;
           } else { sum+= (a[i] * p[i]); }
        }
        else {
            if (used[i] == false) {
        sum+= (a[i] * p[i]);
            }
       }
    }
      cout << sum;
    return 0;
}