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

int main(){
  int n;
  string s;
  cin>>n>>s;
  n++;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  int l=0,r=10001,mid;
  bool h;
  while(l<r){
    mid=(l+r)/2;
    vector<vector<int>> A(n,vector<int>(mid));
    h=true;
    for(int i=0;i<n;i++){
      for(int j=0;j<mid;j++){
        A[i][j]=a[i]/mid+(j<a[i]%mid);
      }
    }
    for(int j=0;j<mid;j++){
      for(int i=0;i<n-1;i++){
        if(s[i]=='>'&&A[i][j]<=A[i+1][j])h=false;
        if(s[i]=='<'&&A[i][j]>=A[i+1][j])h=false;
        if(!h)break;
      }
      if(!h)break;
    }
    if(h)l=mid+1;
    else r=mid;
  }
  l--;
  cout<<l<<endl;
  for(int j=0;j<l;j++){
    for(int i=0;i<n;i++){
      if(i)cout<<" ";
      cout<<a[i]/l+(j<a[i]%l);
    }
    cout<<endl;
  }
}
#include<bits/stdc++.h>
using namespace std;
ostream& operator<<(ostream&o,const pair<auto,auto>&p){return o<<"<"<<p.first<<", "<<p.second<<">";}
ostream& operator<<(ostream&o,const vector<auto>&v){o<<'[';int f=0;for(auto&x:v)(f?o<<", ":o)<<x,f=1;return o<<']';}
#ifdef BIZON
    #define rr(...) [](const auto&...x){ char c='='; cerr << boolalpha << "\e[1;38;5;68m" << #__VA_ARGS__ << " "; ((cerr<<"\e[0;38;5;61m"<<exchange(c,',')<<"\e[0m "<<x),...); cerr<<endl; }(__VA_ARGS__);
#else
    #define rr(...) 0;
    #define endl '\n'
#endif
#define ALL(c) begin(c), end(c)
#define II(...) __VA_ARGS__; [](auto&...x){(cin>>...>>x);}(__VA_ARGS__);
#define ii(...) int II(__VA_ARGS__)
inline bool umin(auto&x, const auto&y){ return y<x && (x=y, 1); }
inline bool umax(auto&x, const auto&y){ return y>x && (x=y, 1); }
using ll = long long;



int main(){
    if(auto f="in.txt"; fopen(f,"r") && freopen(f,"r",stdin));
    ios::sync_with_stdio(0);cin.tie(0);
    
    ii(n)
    vector<int> a(n);
    for(auto &_ : a) cin>>_;
    
    vector<ll> s(n+1);
    vector<map<ll,int>> m(2);
    m[n%2][0] = 1;
    ll ans = 0;
    for(int i=n-1;i>=0;--i){
        s[i] = a[i] - s[i+1];
        
        ans+= m[i%2][s[i]];
        ans+= m[1-i%2][-s[i]];
        
        ++m[i%2][s[i]];
    }
    
    cout<<ans<<endl;
    
    
    return 0;
}
