#include <bits/stdc++.h>
using namespace std;
int c(string a) {
  int sum = 0;
  int p = 1;
  for (int i = a.size() - 1; i >= 1; i--) {
    sum += (a[i] - '0') * p;
    p = p * 10;
  }
  p *= 16;
  sum += 10 * p;
  return sum;
}
void slove() {
  int n;
  cin >> n;
  char a[n];
  cin >> a;
  int sum, sum1;
  sum = sum1 = 0;
  bool x = true;
  for (int i = 0; i < n / 2; i++) {
    if (a[i] == '4' || a[i] == '7')
      sum += a[i] - '0';
    else {
      x = false;
      break;
    }
  }
  for (int i = n / 2; i < n; i++) {
    if (a[i] == '4' || a[i] == '7')
      sum1 += a[i] - '0';
    else
      x = false;
  }
  if (sum == sum1 && x == true)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
int main() { slove(); }
