#include <iostream>
using namespace std;

long long sum(int size,int ary[]);
int min(int size,int ary[]);
int max(int size,int ary[]);
int main(){
	int size=0;
	cin >>size;
	int nums[size];
	for(int i=0;i<size;i++){
		cin >> nums[i];
	}
	
	int a=0,b=0;
	long long c=0;
	a=min(size,nums);
	b=max(size,nums);
	c=sum(size,nums);
	cout <<a<<" "<<b<<" "<<c<<endl;

	return 0;	
}

long long sum(int size,int ary[]){
	long long ret=0;
	for(int i=0;i<size;i++){
		ret +=ary[i];
	}
	return ret;
}

int min(int size,int ary[]){
	int ret=ary[0];
	for(int i=1;i<size;i++){
		if(ary[i]<ret) ret = ary[i];
	}
	return ret;
}

int max(int size,int ary[]){
	int ret=ary[0];
	for(int i=1;i<size;i++){
		if(ary[i]>ret) ret = ary[i];
	}
	return ret;
}
#include <bits/stdc++.h>
#define TOP 0
#define FRONT 1
#define LEFT 2
#define RIGHT 3
#define BACK 4
#define BOTTOM 5
using namespace std;

//TOP,FRONT,LEFT,RIGHT,BACK,BOTTOM
int dice[6]={1,2,4,3,5,6};

//?\\?????¢??????
void rotN(){
  swap(dice[TOP],dice[FRONT]);
  swap(dice[FRONT],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[BACK]);
}

//???????????¢??????
void rotS(){
  //rotN(),rotN(),rotN();
  swap(dice[TOP],dice[BACK]);
  swap(dice[BACK],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[FRONT]);
}


//????????¢??????
void rotE(){
  swap(dice[TOP],dice[LEFT]);
  swap(dice[LEFT],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[RIGHT]);
}

//????????¢??????
void rotW(){
  //rotE(),rotE(),rotE();
  swap(dice[TOP],dice[RIGHT]);
  swap(dice[RIGHT],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[LEFT]);
}

//???????????????????¨????????????????
void rotCW(){
  swap(dice[FRONT],dice[RIGHT]);
  swap(dice[RIGHT],dice[BACK]);
  swap(dice[BACK],dice[LEFT]);
}

//??????????????????????¨???????????????????
void rotCCW(){rotCW(),rotCW(),rotCW();}


int main(){
  cin>>dice[TOP]>>dice[FRONT]>>dice[RIGHT];
  cin>>dice[LEFT]>>dice[BACK]>>dice[BOTTOM];
   
  string str;
  cin>>str;
  for(int i=0;i<str.size();i++){
    if(str[i]=='N') rotN();
    if(str[i]=='S') rotS();
    if(str[i]=='E') rotE();
    if(str[i]=='W') rotW();
  }
 
  cout << dice[TOP]<<endl;
   
}