#include <bits/stdc++.h>
using namespace std;
int n;
char a[100];
int s1;
int main() {
  cin >> n;
  cin >> a;
  for (int i = 0; i < (n / 2); i++) {
    if (a[i] != '4' && a[i] != '7') {
      cout << "NO" << endl;
      return 0;
    }
    s1 += int(a[i] - '0');
  }
  for (int i = n / 2; i < n; i++) {
    if (a[i] != '4' && a[i] != '7') {
      cout << "NO" << endl;
      return 0;
    }
    s1 -= int(a[i] - '0');
  }
  if (s1)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}
