#include <bits/stdc++.h>
using namespace std;
bool checklucky(string a, int n) {
  int sumF = 0, sumS = 0;
  for (int i = 0; i < n / 2; i++) {
    char x = a[i];
    if (x != '4' && x != '7')
      return false;
    else if (x == '4')
      sumF += 4;
    else
      sumF += 7;
  }
  for (int i = n / 2; i < n; i++) {
    char x = a[i];
    if (x != '4' && x != '7')
      return false;
    else if (x == '4')
      sumS += 4;
    else
      sumS += 7;
  }
  if (sumS != sumF)
    return false;
  else
    return true;
}
int main() {
  int n;
  cin >> n;
  string a;
  cin >> a;
  if (checklucky(a, n))
    cout << "YES";
  else
    cout << "NO";
}
