#include <bits/stdc++.h>
using namespace std;
const long long int LL_MAX = 1e18 + 5;
const int MX = INT_MAX;
const long long int mod = 1000000007;
const int maxx = 2e5;
const int d4i[4] = {-1, 0, 1, 0};
const int d4j[4] = {0, 1, 0, -1};
const int d8i[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int d8j[8] = {0, 1, 1, 1, 0, -1, -1, -1};
bool rev(int a, int b) { return a >= b; }
string y = "YES", no = "NO";
void solve() {
  int n;
  cin >> n;
  ;
  string s;
  cin >> s;
  int ls = 0, rs = 0;
  for (auto sss : s) {
    if (sss != '4' && sss != '7') {
      cout << no << "\n";
      return;
    }
  }
  for (int i = (0); i < (n / 2); i++) {
    ls += s[i] - '0';
    rs += s[n - 1 - i] - '0';
  }
  if (ls == rs) {
    cout << y << "\n";
  } else
    cout << no << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
